Discussion:
DropDownChoice and null value
JavaTraveler
2018-06-25 12:26:42 UTC
Permalink
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-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Bas Gooren
2018-06-25 12:30:51 UTC
Permalink
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 (***@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-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
JavaTraveler
2018-06-25 12:38:38 UTC
Permalink
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-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org

Loading...