your solution is correct, but what i would do is add that as a separate behavior instead of merging it into the ajax behavior.
-Igor
On 3/23/06, Siddharth Agarwal <[EMAIL PROTECTED]> wrote:
I add/modify the class attribute through AjaxFormComponentUpdatingBehavior. Is it too late by then?
i ask this since it doesn't show up in the ajax response.
textField.add(new AjaxFormComponentUpdatingBehavior("onblur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
if (!getFormComponent().isValid()) {
getFormComponent().getMarkupAttributes().put("class",
"invalid");
}
target.addComponent(getFormComponent());
}
});
But having it onComponentTag works ..
textField.add(new AjaxFormComponentUpdatingBehavior("onblur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.addComponent(getFormComponent());
}
protected void onComponentTag(final ComponentTag tag){
super.onComponentTag(tag);
if (!getFormComponent().isValid()) {
tag.put("class","invalid");
} else {
tag.put("class","valid");
}
}
});
- Siddharth
