You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by pixologe <pi...@mailinator.com> on 2009/02/20 14:37:33 UTC

DropDownChoice without preselection and without 'Please choose one'

Hi everybody,

I might just be out of it or missing a clue - I'd just like to have a
DropDownChoice without preselection and without 'Please choose one' option.
Is this possible? How can I achieve this?

Thanks in advance + regards
-- 
View this message in context: http://www.nabble.com/DropDownChoice-without-preselection-and-without-%27Please-choose-one%27-tp22120191p22120191.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


Solved: DropDownChoice without preselection and without 'Please choose one'

Posted by pixologe <pi...@mailinator.com>.
I have found a solution for this after all, not quite elegant, but works like
charm :)


new ListMultipleChoice("select",new Model(new ArrayList<T>(0)), new
PropertyModel(this, "choices"), renderer) {
    @Override
    protected void onComponentTag(ComponentTag tag) {
        super.onComponentTag(tag);
        tag.getAttributes().remove("multiple");
    }
};


The trick is to use the multiselect component (because this one neither
requires preselection nor nullValid option.
Having an empty list in the model means nothing is preselected.
Since I do not want it to be multi-selectable, I removed the attribute by
overwriting onComponentTag. 

Thats it :)


-- 
View this message in context: http://www.nabble.com/DropDownChoice-without-preselection-and-without-%27Please-choose-one%27-tp22120191p22120439.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 preselection and without 'Please choose one'

Posted by pixologe <pi...@mailinator.com>.
Hi Johan, hi Martin,

Just for the sake of completeness:
Having
select.null=
select.nullValid=
as string resources, an empty option is displayed as first item if nullValid
is true.
If it is false, there is still the 'Please choose one' option.

Anyway, I'll stick to the ListMultipleChoice solution I have described
before, it might not be the most elegant one, but I think the code is more
comprehensive this way.

Thanks again for your input on this.


Martin Makundi wrote:
> 
> DId you try setting the <componentId>.null <- property value? If null
> is valid then try <componentId>.nullValid , see
> 

-- 
View this message in context: http://www.nabble.com/DropDownChoice-without-preselection-and-without-%27Please-choose-one%27-tp22120191p22159080.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 preselection and without 'Please choose one'

Posted by pixologe <pi...@mailinator.com>.
Sorry, just saw your message.

Didn't know about the .null thing... quite confusing.

I will try this tomorrow.

Thanks a lot



Martin Makundi wrote:
> 
> DId you try setting the <componentId>.null <- property value? If null
> is valid then try <componentId>.nullValid , see
> http://wicket.sourceforge.net/apidocs/wicket/markup/html/form/DropDownChoice.html
> 
> **
> Martin
> 
> 2009/2/20 pixologe <pi...@mailinator.com>:
>>
>> I tried overriding getDefaultChoice already, returning an empty string,
>> this
>> did not work, unfortunately.
>>
>> The 'Please choose one' option is not rendered, however the first
>> 'normal'
>> option gets selected instead.
>> Also, inside AbstractSingleSelectChoice, there remains an empty string in
>> the options list, letting my ChoiceRenderer stumble when it tries to
>> interpret my idExpression :(
>>
>> If there are any more ideas regarding to this, please let me know.
>>
>> Thanks so far!
>>
>> btw.: nullValid is the correct 'Please choose one' string resource key
>>
>>
>>
>> Sergio García wrote:
>>>
>>> I guess that if you simply override the dropdownchoice i18n property
>>> value
>>> for that component/page with a plain "" it may work.
>>>
>>> DropDownChoice property key for "Please choose one" is "null", or at
>>> least
>>> i remember that.
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/DropDownChoice-without-preselection-and-without-%27Please-choose-one%27-tp22120191p22120404.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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/DropDownChoice-without-preselection-and-without-%27Please-choose-one%27-tp22120191p22125830.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 preselection and without 'Please choose one'

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
DId you try setting the <componentId>.null <- property value? If null
is valid then try <componentId>.nullValid , see
http://wicket.sourceforge.net/apidocs/wicket/markup/html/form/DropDownChoice.html

**
Martin

2009/2/20 pixologe <pi...@mailinator.com>:
>
> I tried overriding getDefaultChoice already, returning an empty string, this
> did not work, unfortunately.
>
> The 'Please choose one' option is not rendered, however the first 'normal'
> option gets selected instead.
> Also, inside AbstractSingleSelectChoice, there remains an empty string in
> the options list, letting my ChoiceRenderer stumble when it tries to
> interpret my idExpression :(
>
> If there are any more ideas regarding to this, please let me know.
>
> Thanks so far!
>
> btw.: nullValid is the correct 'Please choose one' string resource key
>
>
>
> Sergio García wrote:
>>
>> I guess that if you simply override the dropdownchoice i18n property value
>> for that component/page with a plain "" it may work.
>>
>> DropDownChoice property key for "Please choose one" is "null", or at least
>> i remember that.
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/DropDownChoice-without-preselection-and-without-%27Please-choose-one%27-tp22120191p22120404.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 preselection and without 'Please choose one'

Posted by pixologe <pi...@mailinator.com>.
just had a deeper look at AbstractSingleChoice.
looks as if it did exactly this when the ###.null string resource is empty.

I will check that out tomorrow.

Thank you guys :)



jcompagner-2 wrote:
> 
> override the getDefaultChoice() and generate a <option><option> (yes
> empty)
> and the if selected is also empty generate <option selected=true><option>
> 

-- 
View this message in context: http://www.nabble.com/DropDownChoice-without-preselection-and-without-%27Please-choose-one%27-tp22120191p22125833.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 preselection and without 'Please choose one'

Posted by Johan Compagner <jc...@gmail.com>.
override the getDefaultChoice() and generate a <option><option> (yes empty)
and the if selected is also empty generate <option selected=true><option>

On Fri, Feb 20, 2009 at 15:31, pixologe <pi...@mailinator.com> wrote:

>
> I tried overriding getDefaultChoice already, returning an empty string,
> this
> did not work, unfortunately.
>
> The 'Please choose one' option is not rendered, however the first 'normal'
> option gets selected instead.
> Also, inside AbstractSingleSelectChoice, there remains an empty string in
> the options list, letting my ChoiceRenderer stumble when it tries to
> interpret my idExpression :(
>
> If there are any more ideas regarding to this, please let me know.
>
> Thanks so far!
>
> btw.: nullValid is the correct 'Please choose one' string resource key
>
>
>
> Sergio García wrote:
> >
> > I guess that if you simply override the dropdownchoice i18n property
> value
> > for that component/page with a plain "" it may work.
> >
> > DropDownChoice property key for "Please choose one" is "null", or at
> least
> > i remember that.
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/DropDownChoice-without-preselection-and-without-%27Please-choose-one%27-tp22120191p22120404.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 preselection and without 'Please choose one'

Posted by pixologe <pi...@mailinator.com>.
I tried overriding getDefaultChoice already, returning an empty string, this
did not work, unfortunately.

The 'Please choose one' option is not rendered, however the first 'normal'
option gets selected instead.
Also, inside AbstractSingleSelectChoice, there remains an empty string in
the options list, letting my ChoiceRenderer stumble when it tries to
interpret my idExpression :(

If there are any more ideas regarding to this, please let me know.

Thanks so far!

btw.: nullValid is the correct 'Please choose one' string resource key



Sergio García wrote:
> 
> I guess that if you simply override the dropdownchoice i18n property value
> for that component/page with a plain "" it may work.
> 
> DropDownChoice property key for "Please choose one" is "null", or at least
> i remember that.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/DropDownChoice-without-preselection-and-without-%27Please-choose-one%27-tp22120191p22120404.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 preselection and without 'Please choose one'

Posted by Sergio García <sg...@denodo.com>.
I guess that if you simply override the dropdownchoice i18n property value
for that component/page with a plain "" it may work.

DropDownChoice property key for "Please choose one" is "null", or at least i
remember that.


-- 
View this message in context: http://www.nabble.com/DropDownChoice-without-preselection-and-without-%27Please-choose-one%27-tp22120191p22120391.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 preselection and without 'Please choose one'

Posted by Fatih Mehmet Ucar <fm...@gmail.com>.
you can use setNullValid(true) method

2009/2/20 pixologe <pi...@mailinator.com>

>
> Hi everybody,
>
> I might just be out of it or missing a clue - I'd just like to have a
> DropDownChoice without preselection and without 'Please choose one' option.
> Is this possible? How can I achieve this?
>
> Thanks in advance + regards
> --
> View this message in context:
> http://www.nabble.com/DropDownChoice-without-preselection-and-without-%27Please-choose-one%27-tp22120191p22120191.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
>
>


-- 
Fatih Mehmet UCAR, Software Engineer
Espresso Education Limited
Riverside Studios,
Crisp Road, London W6 9RL