I think its easier to attach an ajax behaviour to the text field (like
onkeyup) that will push the changes to wicket for validation. You can
use target.addComponent(indicator) to get the indication to be shown
based on the results of the validation.
Look at subclassing AjaxFormComponentUpdatingBehavior which can push the
single field value through to wicket for processing.
You might be able to append the parameter by implementing:
protected IAjaxCallDecorator getAjaxCallDecorator()
{
return null;
}
in your IndicatingAjaxFallbackLink sub class.
But the easiest way is to modify the getCallbackUrl method in the
behaviour itself.
something like this: (I assume that a Component targetComponent is a
private field)
@Override
protected final CharSequence getCallbackScript(boolean
onlyTargetActivePage) {
/*
* Encode the callback script appending to the url the current
client side value of the component values.
*/
CharSequence baseUrl = super.getCallbackUrl(onlyTargetActivePage);
String callbackScript = baseUrl + "&value='+Wicket.$('"
+ targetComponent.getMarkupId() + "').value";
String script = "wicketAjaxGet('" + callbackScript + ");";
return script;
}
This will create url&value=Wicket.$(targetComponent.markupID).value
The second part is to fetch the "value" parameter on the wicket side and
process it:
Request request = RequestCycle.get().getRequest();
String value = request.getParameter("value");
Regards,
Mike
Hi Guys,
I'm trying to implement the typical 'check availability' functionality for a
username.
I have an IndicatingAjaxFallbackLink. I would like to append the value of a
form component [username TextField] to the ajax link as a query parameter.
I've tried:
1. overriding onComponentTag in the IndicatingAjaxFallbackLink but I do not
get access to the getCallbackUrl method
2. add an AbstractDefaultAjaxBehaviour but: 1. End up with onEvent and
onClick and don't know where to put the serverside logic. 2. Am not able to
get the param value from RequestCycle.
The only method that works for me is to submit the whole form without
validation and get the value from the textfield on the serverside.
I would prefer not to submit the whole form.
Appreciate your help with this.
Cheers,
Nim
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]