You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by nitinkc <ni...@yahoo.com> on 2008/06/11 19:14:46 UTC

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Dropdownchoice without default option "choose one"

Posted by nitinkc <ni...@yahoo.com>.
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 <ni...@yahoo.com> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 

-- 
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Dropdownchoice without default option "choose one"

Posted by Gwyn Evans <gw...@gmail.com>.
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 <ni...@yahoo.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Dropdownchoice without default option "choose one"

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
> 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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Dropdownchoice without default option "choose one"

Posted by Timo Rantalaiho <Ti...@ri.fi>.
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 Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Dropdownchoice without default option "choose one"

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
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 <ni...@yahoo.com>:
>
> 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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Dropdownchoice without default option "choose one"

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
If you use ListChoice this option is not there. ListChoice does not
extend AbstractSingleSelectChoice .

**
Martin

2008/6/11 Michael O'Cleirigh <mi...@rivulet.ca>:
> 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: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: How to get context path

Posted by "Hoover, William " <wh...@nemours.org>.
Done: https://issues.apache.org/jira/browse/WICKET-1700 

-----Original Message-----
From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Sent: Thursday, June 12, 2008 11:32 AM
To: users@wicket.apache.org
Subject: Re: How to get context path

jira is your friend

-igor

On Thu, Jun 12, 2008 at 4:46 AM, Hoover, William <wh...@nemours.org>
wrote:
> It would be better if ContextImage was a behavior rather than an 
> actual component. For instance, if you have an html input of 
> type=image (or a link for that matter) you can still utilize the 
> behavior whereas a component you cannot ;o)
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Sent: Wednesday, June 11, 2008 3:29 PM
> To: users@wicket.apache.org
> Subject: Re: How to get context path
>
> see ContextImage
>
> -igor
>
> On Wed, Jun 11, 2008 at 12:10 PM, Patel, Sanjay <sa...@nemours.org>
> wrote:
>> Hi,
>>
>> my images in the application are in webapp/image folder. How to get 
>> Context Path in wicket so I can prepend this path to display the
> image.
>> I am looking for something like this.
>>
>> getContextPath() + "image/icon.gif";
>>
>> Please suggest how to do that.
>>
>> Thanks,
>> Sanjay.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to get context path

Posted by Igor Vaynberg <ig...@gmail.com>.
jira is your friend

-igor

On Thu, Jun 12, 2008 at 4:46 AM, Hoover, William <wh...@nemours.org> wrote:
> It would be better if ContextImage was a behavior rather than an actual
> component. For instance, if you have an html input of type=image (or a
> link for that matter) you can still utilize the behavior whereas a
> component you cannot ;o)
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Sent: Wednesday, June 11, 2008 3:29 PM
> To: users@wicket.apache.org
> Subject: Re: How to get context path
>
> see ContextImage
>
> -igor
>
> On Wed, Jun 11, 2008 at 12:10 PM, Patel, Sanjay <sa...@nemours.org>
> wrote:
>> Hi,
>>
>> my images in the application are in webapp/image folder. How to get
>> Context Path in wicket so I can prepend this path to display the
> image.
>> I am looking for something like this.
>>
>> getContextPath() + "image/icon.gif";
>>
>> Please suggest how to do that.
>>
>> Thanks,
>> Sanjay.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: How to get context path

Posted by "Hoover, William " <wh...@nemours.org>.
It would be better if ContextImage was a behavior rather than an actual
component. For instance, if you have an html input of type=image (or a
link for that matter) you can still utilize the behavior whereas a
component you cannot ;o)

-----Original Message-----
From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Sent: Wednesday, June 11, 2008 3:29 PM
To: users@wicket.apache.org
Subject: Re: How to get context path

see ContextImage

-igor

On Wed, Jun 11, 2008 at 12:10 PM, Patel, Sanjay <sa...@nemours.org>
wrote:
> Hi,
>
> my images in the application are in webapp/image folder. How to get 
> Context Path in wicket so I can prepend this path to display the
image.
> I am looking for something like this.
>
> getContextPath() + "image/icon.gif";
>
> Please suggest how to do that.
>
> Thanks,
> Sanjay.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to get context path

Posted by Igor Vaynberg <ig...@gmail.com>.
see ContextImage

-igor

On Wed, Jun 11, 2008 at 12:10 PM, Patel, Sanjay <sa...@nemours.org> wrote:
> Hi,
>
> my images in the application are in webapp/image folder. How to get
> Context Path in wicket so I can prepend this path to display the image.
> I am looking for something like this.
>
> getContextPath() + "image/icon.gif";
>
> Please suggest how to do that.
>
> Thanks,
> Sanjay.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


How to get context path

Posted by "Patel, Sanjay " <sa...@NEMOURS.ORG>.
Hi,

my images in the application are in webapp/image folder. How to get
Context Path in wicket so I can prepend this path to display the image.
I am looking for something like this.

getContextPath() + "image/icon.gif";

Please suggest how to do that.

Thanks,
Sanjay.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Dropdownchoice without default option "choose one"

Posted by Michael O'Cleirigh <mi...@rivulet.ca>.
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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Dropdownchoice without default option "choose one"

Posted by nitinkc <ni...@yahoo.com>.
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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Dropdownchoice without default option "choose one"

Posted by "micah.k.willard" <mi...@gmail.com>.
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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Dropdownchoice without default option "choose one"

Posted by Michael O'Cleirigh <mi...@rivulet.ca>.
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org