Re: DropDownChoice with -1 value
ty Jeremy, but usually we'll get these values from db. Imagine this, a dropdown of customers, if I do it the way that you said, using a properties file, for each new client, what I have to do? To change that file and It's really bad if you have many inserts. About my trouble, to see what I mean just do an update on data that fills any dropdown putting a negative value on id. something like this: customer_id = -1 thanks. - Original Message - From: "Jeremy Levy" <[EMAIL PROTECTED]> To: Sent: Wednesday, January 02, 2008 6:14 PM Subject: Re: DropDownChoice with -1 value If you create a properties file for the page class and use dot notation matching your page hierarchy but leave the last value as null you can set the default value: For example: theForm.birthdayMonth.null=M theForm.birthdayYear.null=Y theForm.birthdayDay.null=D See if that helps.. J On Jan 2, 2008 2:14 PM, Juliano Gaio <[EMAIL PROTECTED]> wrote: Hello Everybody I'm using wicket.markup.html.form.DropDownChoice and it works fine until now, when I got a suspicious behavior Into database I have one data called "TEMP CUSTOMER" that has id = -1 (it's business logic of our client, that data came through database importation, and I can not update that data) Following my code: List relations = relationManager.list(); final DropDownChoice ddRelations = new DropDownChoice("relation", ( task.getRelation() == null) ? new Model() : new Model(task.getRelation()), relations, new IChoiceRenderer() { public Object getDisplayValue(Object object) { return ((Relation) object).getName(); } public String getIdValue(Object object, int index) { return String.valueOf(((Relation) object).getId()); } }); form.add(ddRelations); and HERE is the source code generate on html : Choose one TEMP CUSTOMER CUSTOMER 1 CUSTOMER 2 .. and so on ... As you can see, there are two options with selected attribute, therefore always "TEMP CUSTOMER" will be selected. When I saw this, I though why in all other dropdownchoices that I had already implemented following the same sample are working very well ? I had no doubts, and I changed the TEMP CUSTOMER id on database to "1" and ... sup.. the dropdownchoice works fine. But I can't change that data, so I rollback, and also the problem rollback. I ask to you , experts guys, if I put a negative value into a dropdownchoice, it will be the default value if none is selected ? How I can do "Choose one" be the default value in this specific case ? Any idea to solve this problem ? Thank you Best Regards Juliano - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DropDownChoice with -1 value
If you create a properties file for the page class and use dot notation matching your page hierarchy but leave the last value as null you can set the default value: For example: theForm.birthdayMonth.null=M theForm.birthdayYear.null=Y theForm.birthdayDay.null=D See if that helps.. J On Jan 2, 2008 2:14 PM, Juliano Gaio <[EMAIL PROTECTED]> wrote: > Hello Everybody > > I'm using wicket.markup.html.form.DropDownChoice and it > works fine until now, when I got a suspicious behavior (maybe bug) > > Into database I have one data called "TEMP CUSTOMER" that has > id = -1 (it's business logic of our client, that data came through > database importation, and I can not update that data) > > Following my code: > > List relations = relationManager.list(); > final DropDownChoice ddRelations = new DropDownChoice("relation", ( > task.getRelation() == null) ? new Model() : new Model(task.getRelation()), > relations, new IChoiceRenderer() { >public Object getDisplayValue(Object object) { > return ((Relation) object).getName(); >} >public String getIdValue(Object object, int index) { > return String.valueOf(((Relation) object).getId()); >} > }); > form.add(ddRelations); > > > and HERE is the source code generate on html : > > > Choose one > TEMP CUSTOMER > CUSTOMER 1 > CUSTOMER 2 .. and so on ... > > As you can see, there are two options with selected attribute, > therefore always "TEMP CUSTOMER" will be selected. > > When I saw this, I though why in all other dropdownchoices > that I had already implemented following the same sample are working very > well ? > I had no doubts, and I changed the TEMP CUSTOMER id > on database to "1" and ... sup.. the dropdownchoice works fine. > > But I can't change that data, so I rollback, and also the > problem rollback. > > I ask to you , experts guys, if I put a negative value into a > dropdownchoice, it will be the default value if none is selected ? > How I can do "Choose one" be the default value in this specific case ? > Any idea to solve this problem ? > > Thank you > > Best Regards > > Juliano >
DropDownChoice with -1 value
Hello Everybody I'm using wicket.markup.html.form.DropDownChoice and it works fine until now, when I got a suspicious behavior (maybe bug) Into database I have one data called "TEMP CUSTOMER" that has id = -1 (it's business logic of our client, that data came through database importation, and I can not update that data) Following my code: List relations = relationManager.list(); final DropDownChoice ddRelations = new DropDownChoice("relation", (task.getRelation() == null) ? new Model() : new Model(task.getRelation()), relations, new IChoiceRenderer() { public Object getDisplayValue(Object object) { return ((Relation) object).getName(); } public String getIdValue(Object object, int index) { return String.valueOf(((Relation) object).getId()); } }); form.add(ddRelations); and HERE is the source code generate on html : Choose one TEMP CUSTOMER CUSTOMER 1 CUSTOMER 2 .. and so on ... As you can see, there are two options with selected attribute, therefore always "TEMP CUSTOMER" will be selected. When I saw this, I though why in all other dropdownchoices that I had already implemented following the same sample are working very well ? I had no doubts, and I changed the TEMP CUSTOMER id on database to "1" and ... sup.. the dropdownchoice works fine. But I can't change that data, so I rollback, and also the problem rollback. I ask to you , experts guys, if I put a negative value into a dropdownchoice, it will be the default value if none is selected ? How I can do "Choose one" be the default value in this specific case ? Any idea to solve this problem ? Thank you Best Regards Juliano