You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by JavaTraveler <me...@gmail.com> on 2018/06/25 12:26:42 UTC

DropDownChoice and null value

Hello everyone, I wish to get rid of the "choose one" option. Wich is
equivalent to null, if i'm not mistaken.

ddlSociete = new DropDownChoice<SocieteDto>("societe", new
PropertyModel<SocieteDto>(pointageMasseSearchDto, "societe"), new
LoadableDetachableModel<List&lt;SocieteDto>>() {
      @Override
      protected List<SocieteDto> load() {
        return societes;
      }
      
    }, new ChoiceRenderer<SocieteDto>("numeroLibelle", "numero"));

I was thinking about imposing a default value to replace the null one with
one from my List.
I tried everything i could find but nothing worked. It can't be that
complicated, can it ?

THanks in advance for your answers.

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

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


Re: DropDownChoice and null value

Posted by JavaTraveler <me...@gmail.com>.
Ok thank you, interesting component. I'll try it :)

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

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


Re: DropDownChoice and null value

Posted by Bas Gooren <ba...@iswd.nl>.
Hi!

See AbstractSingleSelectChoice#setNullValid(boolean)

Of course, it is still shown when the user has not selected a value before
(so null model value at render time). But once a value has been selected
before (so non-null value at render time), the “Choose one” option is not
shown anymore.

To override the “Choose one” text on the initial render, have a look at
AbstractSingleSelectChoice#getDefaultChoice(String), as it documents which
translation keys are used for these cases.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 25 juni 2018 bij 14:26:46, JavaTraveler (meteor.eisen@gmail.com) schreef:

Hello everyone, I wish to get rid of the "choose one" option. Wich is
equivalent to null, if i'm not mistaken.

ddlSociete = new DropDownChoice<SocieteDto>("societe", new
PropertyModel<SocieteDto>(pointageMasseSearchDto, "societe"), new
LoadableDetachableModel<List&lt;SocieteDto>>() {
@Override
protected List<SocieteDto> load() {
return societes;
}

}, new ChoiceRenderer<SocieteDto>("numeroLibelle", "numero"));

I was thinking about imposing a default value to replace the null one with
one from my List.
I tried everything i could find but nothing worked. It can't be that
complicated, can it ?

THanks in advance for your answers.

-- 
Sent from:
http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

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