Thanks Timo...
I tried something similar to this .. It works.
Java :
======
txtAge = new TextField("txtAge", new Model(""));
lblModel = new ErrorLabelModel();
lblAgeValidate = new Label("lblAgeValidate", lblModel);
lblAgeValidate.setOutputMarkupId(true);
txtAge.add(new AjaxFormComponentUpdatingBehavior("onkeyup") {
protected void onUpdate(AjaxRequestTarget target) {
lblModel.setErrorMessage(txtAge.getValue());
target.addComponent(lblAgeValidate);
}
});
ErrorModel:
========
public class ErrorLabelModel extends Model {
public ErrorLabelModel() {
errorMessage = DEFAULT_ERROR_MESSAGE;
}
public void setErrorMessage(String _errorMessage) {
if (_errorMessage == null) {
errorMessage = DEFAULT_ERROR_MESSAGE;
} else {
errorMessage = _errorMessage;
}
}
public Object getObject() {
return errorMessage;
}
private String errorMessage;
private static final String DEFAULT_ERROR_MESSAGE = "";
}
The question is - can this be the fastest way of doing this...
On 7/2/08, Timo Rantalaiho <[EMAIL PROTECTED]> wrote:
> On Wed, 02 Jul 2008, Rakesh Sinha wrote:
> > I want a behavior to attach an ajax event handler to the textfield
> > such a way that anytime a text field changes - there would be an ajax
> > validation performed , that would update the model behind
> > lblAgeValidate - which will contain the error message.
>
>
> Try OnChangeAjaxBehavior. It is the best attempt that I am
> aware of (reacts both to key and mouse input, but has to
> disable the browser autocomplete).
>
> Best wishes,
> Timo
>
>
> --
> Timo Rantalaiho
> Reaktor Innovations Oy <URL: http://www.ri.fi/ >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]