DropDown 'onSelectionChanged()'?

815 views
Skip to first unread message

Chris

unread,
Apr 14, 2011, 6:56:36 AM4/14/11
to visural-wicket
Hi!

I just came accross this library, thanks a lot for providing it. :-)

I'm experimenting with the DropDown combobox and can't figure out how
to implement a master->detail form, i.e. whenever the user selects a
different
item in the DrowDown a detail panel should be updated with the related
data.
E.g. DropDown with a country list, and the details displaying some
more info.

The wicket DropDownChoice widget lets me use the method
onSelectionChanged()
to update detail information without clicking any submit button.
What would be an equivalent way of doing this with the DropDown
widget?
Any help is welcome

Regards
Christian

Chris

unread,
May 19, 2011, 6:23:27 AM5/19/11
to visural-wicket
Hi again!

Still no success. :-(
I tried to add AjaxFormComponentUpdatingBehavior() to the DropDown,
but it is never
called.

dd.add (new AjaxFormComponentUpdatingBehavior(
"onChange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
logger.info("onchange called");
}
protected void onError(AjaxRequestTarget target, RuntimeException
e) {
logger.info("onError called");
}
});


Could anybody point me into the right direction?

Thanks for any info
Christian

Uncle Mike

unread,
May 19, 2011, 7:01:09 AM5/19/11
to visural...@googlegroups.com
Try onClick if your testing with ie. I have had problems with onChange and Internet Explorer.

Sent from my iPhone

Christian Steinebach

unread,
May 19, 2011, 7:27:05 AM5/19/11
to visural...@googlegroups.com
Thank's a lot for your reply, but neither onclick nor onchange seem to work for me. No error message, no exception, nothing happens
when selecting a new value in the DropDown combo. The DropDown is part of a form.

I enclose relevant code.

// the datasource

        serviceDS = new DropDownDataSource<Service>() {
            public String getName() {
                return "services";
            }

            public List<Service> getValues() {
                return proxy.listServices();
            }

            public String getDescriptionForValue(Service r) {
                return r.getName();
            }
        };

// the DropDown

        final DropDown<Service> dd = new DropDown<Service>("service", serviceDS, true);

        dd.setModel(new Model(service));
       
        AjaxFormComponentUpdatingBehavior b = new AjaxFormComponentUpdatingBehavior(
                "onchange") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                logger.info("onchange called");
            }
            protected void onError(AjaxRequestTarget target, RuntimeException e) {
                logger.info("onError called");
            }            
        };

        dd.setOutputMarkupId(true);
        dd.add(b);
--------------

         Christian

--

Christian Steinebach, N-7580 Selbu,Norway



On Thu, 19 May 2011 07:01:09 -0400
Uncle Mike wrote:
> Try onClick if your testing with ie. I have had problems
>with onChange and Internet Explorer.
>
> Sent from my iPhone
>
> On May 19, 2011, at 6:23 AM, Chris
> wrote:
>
>> Hi again!
>>
>> Still no success. :-(
>> I tried to add AjaxFormComponentUpdatingBehavior() to
>>the DropDown,
>> but it is never
>> called.
>>
>> dd.add (new AjaxFormComponentUpdatingBehavior(
>> "onChange") {
>> @Override
>> protected void onUpdate(AjaxRequestTarget
>>target) {
>> logger.info("onchange called");
>> }
>> protected void onError(AjaxRequestTarget
>>target, RuntimeException
>> e) {
>> logger.info("onError called");
>> }
>> });
>>
>>
>> Could anybody point me into the right direction?
>>
>> Thanks for any info
>> Christian
>>
>>
>> On Apr 14, 12:56 pm, Chris

Chris

unread,
May 20, 2011, 5:43:53 AM5/20/11
to visural-wicket
Hi!

I added AjaxFormComponentBehavior("onchange") to a DropDown component.

When using the DropDown in suggestion mode, typing a new
value into the field leads to AjaxFormComponentBehavior.onUpdate()
being called.
When selecting a value from the list the first time (after start-up),
onUpdate() is not called.
When selecting a value from the list a second time, onUpdate() _is_
called.
onUpdate() is never called when using the DropDown in select-only
mode.

Is there a better way of detecting selection changes?

Any help appreciated
Christian



On May 19, 1:01 pm, Uncle Mike <unclemikeb...@gmail.com> wrote:
> Try onClick if your testing with ie. I have had problems with onChange and Internet Explorer.
>
> Sent from my iPhone
>

Richard Nichols

unread,
May 23, 2011, 8:30:04 PM5/23/11
to visural-wicket
Hi Christian,

Sorry I haven't replied before now. I've been really busy lately and
haven't had time to work on visural-wicket.

Selection triggering is something that I am planning on revising in
the next major update to the dropdown component.

Unfortunately at the moment, it's not possible to do this very easily.

There's a number of significant problems with the way the DropDown
component integrates on the client side which I really need to do a
lot of Javascript work to address.

The next release of the project will be v0.7 but it will be mostly a
bug-fix and Wicket 1.5 compatibility release. The next release after
that is likely to be when the DropDown changes make it in.

cheers,
Richard.

Chris

unread,
May 24, 2011, 4:29:02 AM5/24/11
to visural-wicket
Hi Richard!

Thank you for your answer. If I understand you correctly there
is no solution to savely detect selection changes in the DropDown
component as it is implemented now?

Good luck with the next release and I
hope you'll find some time in the future to fix the DropDown. :-)

Christian

Richard Nichols

unread,
May 24, 2011, 6:28:15 AM5/24/11
to visural...@googlegroups.com
There is a method, but it's limited in usefulness... if you take a look at the source - 


You can override this method - 


    /**
* Override to add a javascript call that is invoked whenever the dropdown's actual value changes.
* @return
*/
    public String getOnValueChangeHandler() {
        return "";
    }

This allows you to return some javascript  which will be invoked when the value of the dropdown changes.

For a "must choose a value" type dropdown, this is when the user selects a value from the list. When it's a "suggestion" style dropdown, it's on every key press, or when they choose from the list.

The problem is, this doesn't allow you to integrate with Wicket in the usual/expected way. You have to create your own Javascript integration.

Hopefully I can do a more substantial fix soon.

cheers
Richard
Reply all
Reply to author
Forward
0 new messages