Hello,

What you need to do is add a parameter to the url of the behaviour. But the trick is that you don't attach a fixed string but rather an &otherFieldValue=' + document.getElementById(otherFieldComponentMarkupID).value which will use javascript to extract the current value of the referenced component when the ajax request is initiated.

Then inside the behaviour action you pull the request parameter value in and use it to update the model of the drop down box; then you can proceed normally.

Look at the AbstractDefaultAjaxBehaviour and this method:

    protected CharSequence getCallbackScript(boolean onlyTargetActivePage)
    {
return generateCallbackScript("wicketAjaxGet('" + getCallbackUrl(onlyTargetActivePage) +
            "'");
    }

What you will want is something like this:

    protected CharSequence getCallbackScript(boolean onlyTargetActivePage)
    {
return generateCallbackScript("wicketAjaxGet('" + getCallbackUrl(onlyTargetActivePage) + "&ddcValue='+$Wicket.$("+ddc.getMarkupId()+").value" +
            ");");
    }

Then in fetch the value in the wicket side:
@Override
protected void onEvent(final AjaxRequestTarget target) {
    Request request = RequestCycle.get().getRequest();

    String ddcValue = request.getParameter ("ddcValue");

    // convert the ddc value to into the proper model object

}

You also need to call ddc.setOutputMarkupID (true) since it will need to exist for javascript to find the element in the DOM.

Regards,

Mike

Hi,

  I am looking to submit the selected value from the dropdown to the server ,
on the onblur of the textfield component. Is there a way to do it, though I
have attached the AjaxFormComponentUpdatingBehavior to the textfield but not
to the dropdown box.

Appreciate your help in this regard.

Thanks for your time.
J.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to