Re: 60% waste
Related wiki entry http://cwiki.apache.org/confluence/display/WICKET/Type-safe+testing+in+wicket ** Martin - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice ID's
The golden rule of DropDownChoice is that the values in the list must be the same as the property you are trying to set. In your case, if you want basicDemographicInfo.gender to be set to m or f, you must pass the DropDownChoice the list [ m, f ]. You'll then need a renderer that produces the appropriate display value: new ChoiceRender() { public Object getDisplayValue(Object value) { // here, value will be m or f // look up and return Male or Female accordingly } } You shouldn't care about the ID value. The default provided by ChoiceRenderer should be fine. jk On Sat, May 09, 2009 at 05:52:29PM -0700, Oblivian wrote: basicDemographicInfo.gender is a String and genders is ListString John Krasnay wrote: What is the type of the gender property of BasicDemographicInfo? jk On Sat, May 09, 2009 at 12:39:58PM -0700, Oblivian wrote: Not sure what I'm doing wrong. I need a DropDownChoice with ... option value=fFemale/option option value=mMale/option have a basic class like this ... public class Gender implements Serializable { String id; String name; public Gender(); public Gender(String id, String name); public String getId(); public void setId(String id); public void setName(String name); } A custom ChoiceRenderer ... public class GenderChoiceRenderer implements IChoiceRenderer { public Object getDisplayValue(Object arg0) { return ((Gender) arg0).getName(); } public String getIdValue(Object arg0, int arg1) { // Sometimes this is a String if(arg0 instanceof String){ return (String)arg0; } if (Utility.isNull(arg0)){ return null; } // Other times it is not. return ((Gender) arg0).getId(); } } -- Finally in my Form... add(new DropDownChoice(gender, new PropertyModel(model, basicDemographicInfo.gender), genders, new GenderChoiceRender())); Viewing the HTML, the id's are correct m and f, however in onSubmit, I get this. model.getBasicDemographicInfo().getGender() = com.spinn.sdk.db.model.gen...@30ea3e3c Oblivian wrote: List test = Arrays.asList(new String[] { A, B, C }); add(new DropDownChoice(test, test)); How can I make the Id's match the Values? There coming through as 1,2,3. I've tried custom ChoiceRenderer, but seem to be missing something. Any help is appreciated. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23463880.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23466101.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: CheckboxMultipleChoice in Ajax style
This may confuse the web user quite a bit. It's preferred to send the request each time or cache it maybe. Form form = new Form( form ); List SITES = Arrays.asList(new String[] { The Server Side, Java Lobby, Java.Net }); final ListString values = new LinkedListString(); final CheckBoxMultipleChoice c = new CheckBoxMultipleChoice(site, new Model(), SITES ); c.add( new AjaxFormChoiceComponentUpdatingBehavior(){ @Override protected void onUpdate(AjaxRequestTarget target) { System.out.println( c.getModelObject() ); } }); form.add( c ); add( form ); In this onUpdate you could send to server, cache or whatever. -- View this message in context: http://www.nabble.com/CheckboxMultipleChoice-in-Ajax-style-tp23458553p23470100.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice ID's
After changing genders from ListGender to ListString, I'm seeing the opposite behaviour. The values are coming across as ['m','f'] but the id's are ['0','1'] Overriding getIdValues() instead of getDisplayValues() seems to work. John Krasnay wrote: The golden rule of DropDownChoice is that the values in the list must be the same as the property you are trying to set. In your case, if you want basicDemographicInfo.gender to be set to m or f, you must pass the DropDownChoice the list [ m, f ]. You'll then need a renderer that produces the appropriate display value: new ChoiceRender() { public Object getDisplayValue(Object value) { // here, value will be m or f // look up and return Male or Female accordingly } } You shouldn't care about the ID value. The default provided by ChoiceRenderer should be fine. jk On Sat, May 09, 2009 at 05:52:29PM -0700, Oblivian wrote: basicDemographicInfo.gender is a String and genders is ListString John Krasnay wrote: What is the type of the gender property of BasicDemographicInfo? jk On Sat, May 09, 2009 at 12:39:58PM -0700, Oblivian wrote: Not sure what I'm doing wrong. I need a DropDownChoice with ... option value=fFemale/option option value=mMale/option have a basic class like this ... public class Gender implements Serializable { String id; String name; public Gender(); public Gender(String id, String name); public String getId(); public void setId(String id); public void setName(String name); } A custom ChoiceRenderer ... public class GenderChoiceRenderer implements IChoiceRenderer { public Object getDisplayValue(Object arg0) { return ((Gender) arg0).getName(); } public String getIdValue(Object arg0, int arg1) { // Sometimes this is a String if(arg0 instanceof String){ return (String)arg0; } if (Utility.isNull(arg0)){ return null; } // Other times it is not. return ((Gender) arg0).getId(); } } -- Finally in my Form... add(new DropDownChoice(gender, new PropertyModel(model, basicDemographicInfo.gender), genders, new GenderChoiceRender())); Viewing the HTML, the id's are correct m and f, however in onSubmit, I get this. model.getBasicDemographicInfo().getGender() = com.spinn.sdk.db.model.gen...@30ea3e3c Oblivian wrote: List test = Arrays.asList(new String[] { A, B, C }); add(new DropDownChoice(test, test)); How can I make the Id's match the Values? There coming through as 1,2,3. I've tried custom ChoiceRenderer, but seem to be missing something. Any help is appreciated. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23463880.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23466101.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23470952.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
TabbedPanel problem
Hi, I currently made this simple tab application just to try out how things work. I created Index.java and .html files. Java contains basicaly this: public Index(final PageParameters parameters) { tabs.add(new AbstractTab(new Model(Index)) { public Panel getPanel(String panelID) { return new IndexPlugin(panelID); } }); where IndexPlugin is reusable component (panel). Its purpose is to display text. This is how IndexPlugin.html looks like: ... wicket:panel IT WORKS /wicket:panel ... but when I build the project this is the output: [ERROR]Mojo: [ERROR]org.apache.maven.plugins:maven-surefire-plugin:2.4.2:test [ERROR]FAILED for project: [ERROR]cnl.qos:QoSWebInterface:war:0.1 [ERROR]Reason: [ERROR]There are test failures. [ERROR]Please refer to D:\Projects\QoSWebInterface\target\surefire-reports for the individual test results. and link points that error is in test.assertLabel() method in TestHomePage.java Am I dong something wrong? tm - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: TabbedPanel problem
It looks like you are using the standard wicket quickstart archetype, and you've changed the HomePage (or perhaps deleted it entirely) but haven't altered the corresponding sample test in src/test/java/**/TestHomePage.java, which is expecting to find the Label that the default quickstart puts in HomePage.{java,html}. -Clint 2009/5/10 Tomáš Mihok tomas.mi...@cnl.tuke.sk: Hi, I currently made this simple tab application just to try out how things work. I created Index.java and .html files. Java contains basicaly this: public Index(final PageParameters parameters) { tabs.add(new AbstractTab(new Model(Index)) { public Panel getPanel(String panelID) { return new IndexPlugin(panelID); } }); where IndexPlugin is reusable component (panel). Its purpose is to display text. This is how IndexPlugin.html looks like: ... wicket:panel IT WORKS /wicket:panel ... but when I build the project this is the output: [ERROR]Mojo: [ERROR] org.apache.maven.plugins:maven-surefire-plugin:2.4.2:test [ERROR]FAILED for project: [ERROR] cnl.qos:QoSWebInterface:war:0.1 [ERROR]Reason: [ERROR]There are test failures. [ERROR]Please refer to D:\Projects\QoSWebInterface\target\surefire-reports for the individual test results. and link points that error is in test.assertLabel() method in TestHomePage.java Am I dong something wrong? tm - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Clint Popetz http://42lines.net Scalable Web Application Development - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: TabbedPanel problem
Thank you for your reply, I just chcecked the test but it seems OK public void testRenderMyPage() { //start and render the test page tester.startPage(Index.class); //assert rendered page class tester.assertRenderedPage(Index.class); //assert rendered label component tester.assertLabel(message, If you see this message wicket is properly configured and running); } as I have used Refactor to rename HomePage to Index. Soyou think this might be the problem? tm Clint Popetz wrote / napísal(a): It looks like you are using the standard wicket quickstart archetype, and you've changed the HomePage (or perhaps deleted it entirely) but haven't altered the corresponding sample test in src/test/java/**/TestHomePage.java, which is expecting to find the Label that the default quickstart puts in HomePage.{java,html}. -Clint 2009/5/10 Tomáš Mihok tomas.mi...@cnl.tuke.sk: Hi, I currently made this simple tab application just to try out how things work. I created Index.java and .html files. Java contains basicaly this: public Index(final PageParameters parameters) { tabs.add(new AbstractTab(new Model(Index)) { public Panel getPanel(String panelID) { return new IndexPlugin(panelID); } }); where IndexPlugin is reusable component (panel). Its purpose is to display text. This is how IndexPlugin.html looks like: ... wicket:panel IT WORKS /wicket:panel ... but when I build the project this is the output: [ERROR]Mojo: [ERROR]org.apache.maven.plugins:maven-surefire-plugin:2.4.2:test [ERROR]FAILED for project: [ERROR]cnl.qos:QoSWebInterface:war:0.1 [ERROR]Reason: [ERROR]There are test failures. [ERROR]Please refer to D:\Projects\QoSWebInterface\target\surefire-reports for the individual test results. and link points that error is in test.assertLabel() method in TestHomePage.java Am I dong something wrong? tm - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: TabbedPanel problem
assertLabel is looking for a top-level label component with wicket:id label and it's not finding one. You'll need to post Index.html if you want me to tell you why, but I'm guessing you could look at Index.html and see if it has a message label contained by no other wicket components, and also whether Index.java is still adding that label to the page. You need to stop and think about the exception you're getting. Step through it in the debugger. What's it telling you? -Clint 2009/5/10 Tomáš Mihok tomas.mi...@cnl.tuke.sk: Thank you for your reply, I just chcecked the test but it seems OK public void testRenderMyPage() { //start and render the test page tester.startPage(Index.class); //assert rendered page class tester.assertRenderedPage(Index.class); //assert rendered label component tester.assertLabel(message, If you see this message wicket is properly configured and running); } as I have used Refactor to rename HomePage to Index. Soyou think this might be the problem? tm Clint Popetz wrote / napísal(a): It looks like you are using the standard wicket quickstart archetype, and you've changed the HomePage (or perhaps deleted it entirely) but haven't altered the corresponding sample test in src/test/java/**/TestHomePage.java, which is expecting to find the Label that the default quickstart puts in HomePage.{java,html}. -Clint 2009/5/10 Tomáš Mihok tomas.mi...@cnl.tuke.sk: Hi, I currently made this simple tab application just to try out how things work. I created Index.java and .html files. Java contains basicaly this: public Index(final PageParameters parameters) { tabs.add(new AbstractTab(new Model(Index)) { public Panel getPanel(String panelID) { return new IndexPlugin(panelID); } }); where IndexPlugin is reusable component (panel). Its purpose is to display text. This is how IndexPlugin.html looks like: ... wicket:panel IT WORKS /wicket:panel ... but when I build the project this is the output: [ERROR]Mojo: [ERROR] org.apache.maven.plugins:maven-surefire-plugin:2.4.2:test [ERROR]FAILED for project: [ERROR] cnl.qos:QoSWebInterface:war:0.1 [ERROR]Reason: [ERROR]There are test failures. [ERROR]Please refer to D:\Projects\QoSWebInterface\target\surefire-reports for the individual test results. and link points that error is in test.assertLabel() method in TestHomePage.java Am I dong something wrong? tm - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Clint Popetz http://42lines.net Scalable Web Application Development - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice ID's
Why do you care what the id's are? Wicket doesn't store the ID anywhere, it just uses the ID to look up the list element to put into the model. jk On Sun, May 10, 2009 at 08:08:30AM -0700, Oblivian wrote: After changing genders from ListGender to ListString, I'm seeing the opposite behaviour. The values are coming across as ['m','f'] but the id's are ['0','1'] Overriding getIdValues() instead of getDisplayValues() seems to work. John Krasnay wrote: The golden rule of DropDownChoice is that the values in the list must be the same as the property you are trying to set. In your case, if you want basicDemographicInfo.gender to be set to m or f, you must pass the DropDownChoice the list [ m, f ]. You'll then need a renderer that produces the appropriate display value: new ChoiceRender() { public Object getDisplayValue(Object value) { // here, value will be m or f // look up and return Male or Female accordingly } } You shouldn't care about the ID value. The default provided by ChoiceRenderer should be fine. jk On Sat, May 09, 2009 at 05:52:29PM -0700, Oblivian wrote: basicDemographicInfo.gender is a String and genders is ListString John Krasnay wrote: What is the type of the gender property of BasicDemographicInfo? jk On Sat, May 09, 2009 at 12:39:58PM -0700, Oblivian wrote: Not sure what I'm doing wrong. I need a DropDownChoice with ... option value=fFemale/option option value=mMale/option have a basic class like this ... public class Gender implements Serializable { String id; String name; public Gender(); public Gender(String id, String name); public String getId(); public void setId(String id); public void setName(String name); } A custom ChoiceRenderer ... public class GenderChoiceRenderer implements IChoiceRenderer { public Object getDisplayValue(Object arg0) { return ((Gender) arg0).getName(); } public String getIdValue(Object arg0, int arg1) { // Sometimes this is a String if(arg0 instanceof String){ return (String)arg0; } if (Utility.isNull(arg0)){ return null; } // Other times it is not. return ((Gender) arg0).getId(); } } -- Finally in my Form... add(new DropDownChoice(gender, new PropertyModel(model, basicDemographicInfo.gender), genders, new GenderChoiceRender())); Viewing the HTML, the id's are correct m and f, however in onSubmit, I get this. model.getBasicDemographicInfo().getGender() = com.spinn.sdk.db.model.gen...@30ea3e3c Oblivian wrote: List test = Arrays.asList(new String[] { A, B, C }); add(new DropDownChoice(test, test)); How can I make the Id's match the Values? There coming through as 1,2,3. I've tried custom ChoiceRenderer, but seem to be missing something. Any help is appreciated. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23463880.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23466101.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23470952.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe,
Re: 60% waste
Ben Tilford wrote: Have you looked at selenium? Your not really unit testing here. Hi Ben, What do you mean Your not really unit testing here. ? MSi On Sat, May 9, 2009 at 7:41 AM, Marko Sibakov marko.siba...@ri.fi wrote: Like Martijn said i also strongly recommend to take a look at the jdave-wicket's selectors (http://www.jdave.org/). examples = http://svn.laughingpanda.org/svn/jdave/trunk/jdave-wicket/src/test/jdave/wicket/PageWithItemsSpec.java with form tester it goes like this = form = wicket.newFormTester(selectFirst(Form.class, form).from(panel).getPageRelativePath()); form.setValue(name, wicket); form.setValue(address, jdave); form.submit(); MSi Martijn Dashorst wrote: See jdave-wicket for better test support. Slated to come to you in Wicket 1.5 Martijn On Fri, May 8, 2009 at 5:48 PM, Martin Makundi martin.maku...@koodaripalvelut.com wrote: Hi! I use TDD: I spend 60% of my time type-checking and path-checking my wicketTests and components. I always have the wrong path and I must prinDocument and iterate to get it right Anybody have the same experience? How about introducing type-safety and path-safety/identity into component hierarchies? Can this be done? ** Martin - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
objectautocomplete on a form with CompoundPropertyModel
I'm trying to use ObjectAutoComplete from wicketstuff on a form where the model is a CompoundPropertyModel. The auto compete field doesn't seem to be setting its value on the form model at all during a submit. I've looked at the examples for this component and not a single one actually includes the onSubmit implementation. Is there something special i have to do with this component? - Brill Pappin smime.p7s Description: S/MIME cryptographic signature
Re: 60% waste
unit testing is about testing small isolated bits of functionality in isolation lets say that you want to test foo(p) { return a(b(c(p))); } what martin is trying to do is to test that foo(q) yields the desired value w, what he should do instead is test a() in isolation to make sure it works test b() in isolation to make sure it works test c() in isolation to make sure it works test that foo() calls a,b,c. if all small tests above pass you are guaranteed that foo() works. -igor On Sun, May 10, 2009 at 9:55 PM, Marko Sibakov marko.siba...@ri.fi wrote: Ben Tilford wrote: Have you looked at selenium? Your not really unit testing here. Hi Ben, What do you mean Your not really unit testing here. ? MSi On Sat, May 9, 2009 at 7:41 AM, Marko Sibakov marko.siba...@ri.fi wrote: Like Martijn said i also strongly recommend to take a look at the jdave-wicket's selectors (http://www.jdave.org/). examples = http://svn.laughingpanda.org/svn/jdave/trunk/jdave-wicket/src/test/jdave/wicket/PageWithItemsSpec.java with form tester it goes like this = form = wicket.newFormTester(selectFirst(Form.class, form).from(panel).getPageRelativePath()); form.setValue(name, wicket); form.setValue(address, jdave); form.submit(); MSi Martijn Dashorst wrote: See jdave-wicket for better test support. Slated to come to you in Wicket 1.5 Martijn On Fri, May 8, 2009 at 5:48 PM, Martin Makundi martin.maku...@koodaripalvelut.com wrote: Hi! I use TDD: I spend 60% of my time type-checking and path-checking my wicketTests and components. I always have the wrong path and I must prinDocument and iterate to get it right Anybody have the same experience? How about introducing type-safety and path-safety/identity into component hierarchies? Can this be done? ** Martin - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org