Re: Dropdownchoice without default option "choose one"
I noticed this thread never had a very conclusive answer, so I hope you don't mind if I resurrect it. nitinkc, where are you setting this at? Does it happen to be in the DDC onInit method? I ask, because I have noticed that when it is placed there, it is ignored. Instead I assign the DDC to a var and then do "var.setNullValid(false);", before adding it. This removes the null value for me every time. nitinkc wrote > I tried setNullValid(false). But this does not get rid of the "choose one" > option. Note that the choices are a list of Strings. If the choices are a > list of other user defined object types and I use a choicerendrer for > display values, the "choose one" option is removed(without > setNullValid(false)). Any ideas? > Michael O'Cleirigh wrote >> Hi nitinkc, >> >> Calling setNullValid (false) on the drop down choice should get rid of >> the default "choose one" text. >> >> If the ddc model should always have a value defined then you could set >> the model object to be for example the first choice. >> >> e.g. ddc.setModelObject (ddc.getChoices().get(0)); >> >> Regards, >> >> Mike >> >>> I would like to remove the default "choose one" option from the >>> DropDownChoice component. >>> Does anyone know how to do this. Thanks. >>> >> >> >> ----- >> 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://apache-wicket.1842946.n4.nabble.com/Dropdownchoice-without-default-option-choose-one-tp1866175p4668398.html Sent from the Users forum 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 without default option "choose one"
Thanks gwyn! I was not adding the default value to the ddc and that's why it was showing the "choose one" option. As you said, it's best to do that in the constructor. Gwyn wrote: > > Just to summarise, you need to do two things: set a 'current selection' > and > call setNullValid(false). > > /Gwyn > > On Wed, Jun 11, 2008 at 6:14 PM, nitinkc <[EMAIL PROTECTED]> wrote: > >> >> I would like to remove the default "choose one" option from the >> DropDownChoice component. >> Does anyone know how to do this. Thanks. >> -- >> View this message in context: >> http://www.nabble.com/Dropdownchoice-without-default-option-%22choose-one%22-tp17782776p17782776.html >> Sent from the Wicket - User mailing list archive at Nabble.com. >> >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > -- View this message in context: http://www.nabble.com/Dropdownchoice-without-default-option-%22choose-one%22-tp17782776p17786956.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dropdownchoice without default option "choose one"
Just to summarise, you need to do two things: set a 'current selection' and call setNullValid(false). /Gwyn On Wed, Jun 11, 2008 at 6:14 PM, nitinkc <[EMAIL PROTECTED]> wrote: > > I would like to remove the default "choose one" option from the > DropDownChoice component. > Does anyone know how to do this. Thanks. > -- > View this message in context: > http://www.nabble.com/Dropdownchoice-without-default-option-%22choose-one%22-tp17782776p17782776.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Dropdownchoice without default option "choose one"
If you use ListChoice this option is not there. ListChoice does not extend AbstractSingleSelectChoice . ** Martin 2008/6/11 Michael O'Cleirigh <[EMAIL PROTECTED]>: > Hi nitinkc, > > The "Choose One" option is actually defined in: > public abstract class AbstractSingleSelectChoice extends AbstractChoice > { > /** >* >*/ > private static final long serialVersionUID = 1L; > > /** String to display when the selected value is null and nullValid is > false. */ > private static final String CHOOSE_ONE = "Choose One"; > . > . > . > > > You should look at overriding this method: > > protected CharSequence getDefaultChoice(final Object selected) in > AbstractSingleSelectionChoice > > It looks to me like if you return EMPTY_STRING then no default choice will > be rendered into the options list. > > > Mike > >> I tried setNullValid(false). But this does not get rid of the "choose one" >> option. Note that the choices are a list of Strings. If the choices are a >> list of other user defined object types and I use a choicerendrer for >> display values, the "choose one" option is removed(without >> setNullValid(false)). Any ideas? >> >> >> Michael O'Cleirigh wrote: >> >>> >>> Hi nitinkc, >>> >>> Calling setNullValid (false) on the drop down choice should get rid of >>> the default "choose one" text. >>> >>> If the ddc model should always have a value defined then you could set >>> the model object to be for example the first choice. >>> >>> e.g. ddc.setModelObject (ddc.getChoices().get(0)); >>> >>> Regards, >>> >>> Mike >>> >>> I would like to remove the default "choose one" option from the DropDownChoice component. Does anyone know how to do this. Thanks. >>> >>> - >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >>> >>> >> >> > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dropdownchoice without default option "choose one"
Hi nitinkc, The "Choose One" option is actually defined in: public abstract class AbstractSingleSelectChoice extends AbstractChoice { /** * */ private static final long serialVersionUID = 1L; /** String to display when the selected value is null and nullValid is false. */ private static final String CHOOSE_ONE = "Choose One"; . . . You should look at overriding this method: protected CharSequence getDefaultChoice(final Object selected) in AbstractSingleSelectionChoice It looks to me like if you return EMPTY_STRING then no default choice will be rendered into the options list. Mike I tried setNullValid(false). But this does not get rid of the "choose one" option. Note that the choices are a list of Strings. If the choices are a list of other user defined object types and I use a choicerendrer for display values, the "choose one" option is removed(without setNullValid(false)). Any ideas? Michael O'Cleirigh wrote: Hi nitinkc, Calling setNullValid (false) on the drop down choice should get rid of the default "choose one" text. If the ddc model should always have a value defined then you could set the model object to be for example the first choice. e.g. ddc.setModelObject (ddc.getChoices().get(0)); Regards, Mike I would like to remove the default "choose one" option from the DropDownChoice component. Does anyone know how to do this. Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dropdownchoice without default option "choose one"
> Yeah, it's easy to miss setting the currently selected value > for when DropDownChoice is rendered for the first time. > Hence it's always a good idea to supply it in the > constructor. I have noticed the problem when I have a propertymodel attached to the dropdown, and I have two chained dropdowns ... I haven't studied it much, could fairly well be a stupid user bug. ** Martin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dropdownchoice without default option "choose one"
On Wed, 11 Jun 2008, Martin Makundi wrote: > I have noticed that with DropDownChoice, if the currently selected > value is Null, you get this "choose one" item. And sometimes in a > dynamic situation you get it still. Yeah, it's easy to miss setting the currently selected value for when DropDownChoice is rendered for the first time. Hence it's always a good idea to supply it in the constructor. It can get tricky if you want to have the default choice in the UI, but not necessarily update it to the domain object property that the selection is bound to. If this is required, you can get around it by a custom model. Best wishes, Timo -- Timo Rantalaiho Reaktor Innovations Oyhttp://www.ri.fi/ > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dropdownchoice without default option "choose one"
I have noticed that with DropDownChoice, if the currently selected value is Null, you get this "choose one" item. And sometimes in a dynamic situation you get it still. Try using the analogous ListChoice element, at least it worked for me. ** Martin 2008/6/11 nitinkc <[EMAIL PROTECTED]>: > > I tried setNullValid(false). But this does not get rid of the "choose one" > option. Note that the choices are a list of Strings. If the choices are a > list of other user defined object types and I use a choicerendrer for > display values, the "choose one" option is removed(without > setNullValid(false)). Any ideas? > > > Michael O'Cleirigh wrote: >> >> Hi nitinkc, >> >> Calling setNullValid (false) on the drop down choice should get rid of >> the default "choose one" text. >> >> If the ddc model should always have a value defined then you could set >> the model object to be for example the first choice. >> >> e.g. ddc.setModelObject (ddc.getChoices().get(0)); >> >> Regards, >> >> Mike >> >>> I would like to remove the default "choose one" option from the >>> DropDownChoice component. >>> Does anyone know how to do this. Thanks. >>> >> >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > > -- > View this message in context: > http://www.nabble.com/Dropdownchoice-without-default-option-%22choose-one%22-tp17782776p17783862.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dropdownchoice without default option "choose one"
I tried setNullValid(false). But this does not get rid of the "choose one" option. Note that the choices are a list of Strings. If the choices are a list of other user defined object types and I use a choicerendrer for display values, the "choose one" option is removed(without setNullValid(false)). Any ideas? Michael O'Cleirigh wrote: > > Hi nitinkc, > > Calling setNullValid (false) on the drop down choice should get rid of > the default "choose one" text. > > If the ddc model should always have a value defined then you could set > the model object to be for example the first choice. > > e.g. ddc.setModelObject (ddc.getChoices().get(0)); > > Regards, > > Mike > >> I would like to remove the default "choose one" option from the >> DropDownChoice component. >> Does anyone know how to do this. Thanks. >> > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Dropdownchoice-without-default-option-%22choose-one%22-tp17782776p17783862.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dropdownchoice without default option "choose one"
Hi nitinkc, Calling setNullValid (false) on the drop down choice should get rid of the default "choose one" text. If the ddc model should always have a value defined then you could set the model object to be for example the first choice. e.g. ddc.setModelObject (ddc.getChoices().get(0)); Regards, Mike I would like to remove the default "choose one" option from the DropDownChoice component. Does anyone know how to do this. Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Dropdownchoice without default option "choose one"
I would like to remove the default "choose one" option from the DropDownChoice component. Does anyone know how to do this. Thanks. -- View this message in context: http://www.nabble.com/Dropdownchoice-without-default-option-%22choose-one%22-tp17782776p17782776.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]