You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris <ch...@gmx.at> on 2015/05/12 12:44:57 UTC
Drop Down Choice default value
Hi all,
I have a Drop down choice field and would like to override the default select value.
I have made following settings but the default value is empty. Is there sth missing?
setNullValid(true);
@Override
protected String getNullKeyDisplayValue() {
return "Please choose";
}
Thanks, Chris
Re: Drop Down Choice default value
Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi,
see
http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/ajax/AjaxEventBehavior.html
use change event.
kind regards
Tobias
> Am 18.05.2015 um 00:03 schrieb Chris <ch...@gmx.at>:
>
> Hi,
>
> when using a drop down as follows, always the whole page is reloaded on drop down change.
>
> How is it possible to update only a specific component via ajax?
>
> Thanks,
> Chris
>
>
>
> DropDownChoice tag = new DropDownChoice<String>("tags", new PropertyModel<String>(this, "selectedCategory"), displayCategories) {
>
> @Override
> protected boolean wantOnSelectionChangedNotifications() {
> return true;
> }
>
> @Override
> protected void onSelectionChanged(String newSelection) {
> super.onSelectionChanged(newSelection);
> selectedCategory = newSelection;
>
> }
>
>
> @Override
> protected String getNullValidDisplayValue() {
> return "All";
> }
>
> };
>
>
> tag.add(new AjaxFormComponentUpdatingBehavior("onchange") {
> private static final long serialVersionUID = 1L;
> @Override
> protected void onUpdate(AjaxRequestTarget target) {
> target.add(...);
> }
> });
>
>
>
>> Am 12.05.2015 um 23:49 schrieb Chris <ch...@gmx.at>:
>>
>> Marcel, Sven,
>>
>> thanks a lot for your answers!
>> Chris
>>
>>
>>> Am 12.05.2015 um 15:24 schrieb Marcel Barbosa Pinto <ma...@gmail.com>:
>>>
>>> Another way is to provide a value on your .properties file.
>>>
>>> For instance:
>>>
>>> nullValid=Please choose
>>> myFieldId.nullValid=Please choose a value for ${label}
>>>
>>>> On Tue, May 12, 2015 at 8:26 AM, Sven Meier <sv...@meiers.net> wrote:
>>>>
>>>> Hi,
>>>>
>>>> you have to override #getNullValidDisplayValue(),
>>>> #getNullKeyDisplayValue() is for cases where null is *not* valid.
>>>>
>>>> Regards
>>>> Sven
>>>>
>>>>
>>>>
>>>>> On 12.05.2015 12:44, Chris wrote:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> I have a Drop down choice field and would like to override the default
>>>>> select value.
>>>>>
>>>>> I have made following settings but the default value is empty. Is there
>>>>> sth missing?
>>>>>
>>>>> setNullValid(true);
>>>>> @Override
>>>>> protected String getNullKeyDisplayValue() {
>>>>> return "Please choose";
>>>>> }
>>>>> Thanks, Chris
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>> --
>>>
>>> Marcel Barbosa Pinto
>>> 55 11 98255 8288
>>
>>
>> ---------------------------------------------------------------------
>> 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: Drop Down Choice default value
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi,
On Mon, May 18, 2015 at 12:03 AM, Chris <ch...@gmx.at> wrote:
> Hi,
>
> when using a drop down as follows, always the whole page is reloaded on
> drop down change.
>
> How is it possible to update only a specific component via ajax?
>
> Thanks,
> Chris
>
>
>
> DropDownChoice tag = new DropDownChoice<String>("tags", new
> PropertyModel<String>(this, "selectedCategory"), displayCategories) {
>
> @Override
> protected boolean wantOnSelectionChangedNotifications() {
> return true;
> }
>
This is what is triggering page reload... Do not override it and everything
should work. Use the source Luke
/**
* Whether this component's onSelectionChanged event handler should be
called using javascript
* <tt>window.location</tt> if the selection changes. If true, a roundtrip
will be generated
* with each selection change, resulting in the model being updated (of
just this component) and
* onSelectionChanged being called. This method returns false by default.
If you wish to use
* Ajax instead, let {@link #wantOnSelectionChangedNotifications()} return
false and add an
* {@link AjaxFormComponentUpdatingBehavior} to the component using the
<tt>onchange</tt> event.
*
* @return True if this component's onSelectionChanged event handler should
called using
* javascript if the selection changes
*/
protected boolean wantOnSelectionChangedNotifications()
{
return false;
}
>
> @Override
> protected void onSelectionChanged(String newSelection) {
> super.onSelectionChanged(newSelection);
> selectedCategory = newSelection;
>
> }
>
>
> @Override
> protected String getNullValidDisplayValue() {
> return "All";
> }
>
> };
>
>
> tag.add(new AjaxFormComponentUpdatingBehavior("onchange") {
> private static final long serialVersionUID = 1L;
> @Override
> protected void onUpdate(AjaxRequestTarget target) {
> target.add(...);
> }
> });
>
>
>
> > Am 12.05.2015 um 23:49 schrieb Chris <ch...@gmx.at>:
> >
> > Marcel, Sven,
> >
> > thanks a lot for your answers!
> > Chris
> >
> >
> >> Am 12.05.2015 um 15:24 schrieb Marcel Barbosa Pinto <
> marcel.power@gmail.com>:
> >>
> >> Another way is to provide a value on your .properties file.
> >>
> >> For instance:
> >>
> >> nullValid=Please choose
> >> myFieldId.nullValid=Please choose a value for ${label}
> >>
> >> On Tue, May 12, 2015 at 8:26 AM, Sven Meier <sv...@meiers.net> wrote:
> >>
> >>> Hi,
> >>>
> >>> you have to override #getNullValidDisplayValue(),
> >>> #getNullKeyDisplayValue() is for cases where null is *not* valid.
> >>>
> >>> Regards
> >>> Sven
> >>>
> >>>
> >>>
> >>> On 12.05.2015 12:44, Chris wrote:
> >>>
> >>>> Hi all,
> >>>>
> >>>> I have a Drop down choice field and would like to override the default
> >>>> select value.
> >>>>
> >>>> I have made following settings but the default value is empty. Is
> there
> >>>> sth missing?
> >>>>
> >>>> setNullValid(true);
> >>>> @Override
> >>>> protected String getNullKeyDisplayValue() {
> >>>> return "Please choose";
> >>>> }
> >>>> Thanks, Chris
> >>>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>>
> >>
> >>
> >> --
> >>
> >> Marcel Barbosa Pinto
> >> 55 11 98255 8288
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
--
Regards - Ernesto Reinaldo Barreiro
Re: Drop Down Choice default value
Posted by Chris <ch...@gmx.at>.
Hi,
when using a drop down as follows, always the whole page is reloaded on drop down change.
How is it possible to update only a specific component via ajax?
Thanks,
Chris
DropDownChoice tag = new DropDownChoice<String>("tags", new PropertyModel<String>(this, "selectedCategory"), displayCategories) {
@Override
protected boolean wantOnSelectionChangedNotifications() {
return true;
}
@Override
protected void onSelectionChanged(String newSelection) {
super.onSelectionChanged(newSelection);
selectedCategory = newSelection;
}
@Override
protected String getNullValidDisplayValue() {
return "All";
}
};
tag.add(new AjaxFormComponentUpdatingBehavior("onchange") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(...);
}
});
> Am 12.05.2015 um 23:49 schrieb Chris <ch...@gmx.at>:
>
> Marcel, Sven,
>
> thanks a lot for your answers!
> Chris
>
>
>> Am 12.05.2015 um 15:24 schrieb Marcel Barbosa Pinto <ma...@gmail.com>:
>>
>> Another way is to provide a value on your .properties file.
>>
>> For instance:
>>
>> nullValid=Please choose
>> myFieldId.nullValid=Please choose a value for ${label}
>>
>> On Tue, May 12, 2015 at 8:26 AM, Sven Meier <sv...@meiers.net> wrote:
>>
>>> Hi,
>>>
>>> you have to override #getNullValidDisplayValue(),
>>> #getNullKeyDisplayValue() is for cases where null is *not* valid.
>>>
>>> Regards
>>> Sven
>>>
>>>
>>>
>>> On 12.05.2015 12:44, Chris wrote:
>>>
>>>> Hi all,
>>>>
>>>> I have a Drop down choice field and would like to override the default
>>>> select value.
>>>>
>>>> I have made following settings but the default value is empty. Is there
>>>> sth missing?
>>>>
>>>> setNullValid(true);
>>>> @Override
>>>> protected String getNullKeyDisplayValue() {
>>>> return "Please choose";
>>>> }
>>>> Thanks, Chris
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>>
>> --
>>
>> Marcel Barbosa Pinto
>> 55 11 98255 8288
>
>
> ---------------------------------------------------------------------
> 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: Drop Down Choice default value
Posted by Chris <ch...@gmx.at>.
Marcel, Sven,
thanks a lot for your answers!
Chris
> Am 12.05.2015 um 15:24 schrieb Marcel Barbosa Pinto <ma...@gmail.com>:
>
> Another way is to provide a value on your .properties file.
>
> For instance:
>
> nullValid=Please choose
> myFieldId.nullValid=Please choose a value for ${label}
>
> On Tue, May 12, 2015 at 8:26 AM, Sven Meier <sv...@meiers.net> wrote:
>
>> Hi,
>>
>> you have to override #getNullValidDisplayValue(),
>> #getNullKeyDisplayValue() is for cases where null is *not* valid.
>>
>> Regards
>> Sven
>>
>>
>>
>> On 12.05.2015 12:44, Chris wrote:
>>
>>> Hi all,
>>>
>>> I have a Drop down choice field and would like to override the default
>>> select value.
>>>
>>> I have made following settings but the default value is empty. Is there
>>> sth missing?
>>>
>>> setNullValid(true);
>>> @Override
>>> protected String getNullKeyDisplayValue() {
>>> return "Please choose";
>>> }
>>> Thanks, Chris
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
>
> Marcel Barbosa Pinto
> 55 11 98255 8288
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Drop Down Choice default value
Posted by Marcel Barbosa Pinto <ma...@gmail.com>.
Another way is to provide a value on your .properties file.
For instance:
nullValid=Please choose
myFieldId.nullValid=Please choose a value for ${label}
On Tue, May 12, 2015 at 8:26 AM, Sven Meier <sv...@meiers.net> wrote:
> Hi,
>
> you have to override #getNullValidDisplayValue(),
> #getNullKeyDisplayValue() is for cases where null is *not* valid.
>
> Regards
> Sven
>
>
>
> On 12.05.2015 12:44, Chris wrote:
>
>> Hi all,
>>
>> I have a Drop down choice field and would like to override the default
>> select value.
>>
>> I have made following settings but the default value is empty. Is there
>> sth missing?
>>
>> setNullValid(true);
>> @Override
>> protected String getNullKeyDisplayValue() {
>> return "Please choose";
>> }
>> Thanks, Chris
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Marcel Barbosa Pinto
55 11 98255 8288
Re: Drop Down Choice default value
Posted by Sven Meier <sv...@meiers.net>.
Hi,
you have to override #getNullValidDisplayValue(),
#getNullKeyDisplayValue() is for cases where null is *not* valid.
Regards
Sven
On 12.05.2015 12:44, Chris wrote:
> Hi all,
>
> I have a Drop down choice field and would like to override the default select value.
>
> I have made following settings but the default value is empty. Is there sth missing?
>
> setNullValid(true);
> @Override
> protected String getNullKeyDisplayValue() {
> return "Please choose";
> }
> Thanks, Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org