This content has been marked as final.
Show 3 replies
-
1. Re: Ajax Validator: Field Highlighting on validation error
ilya_shaikovsky Apr 1, 2009 7:40 AM (in response to techieexchange)you could add ajaxListener (it called before render responce so even if validation failed) which will check if the messages exist and which components rised them and add proper styleClasses.
-
2. Re: Ajax Validator: Field Highlighting on validation error
techieexchange Apr 2, 2009 8:18 AM (in response to techieexchange)"ilya_shaikovsky" wrote:
you could add ajaxListener (it called before render responce so even if validation failed) which will check if the messages exist and which components rised them and add proper styleClasses.
I tried to add a ajaxListener like this<s:div id="myinputdiv"> <h:inputText id="input1" value="#{testBean.someInputText}" > <f:validateLength minimum="3" maximum="12"/> <rich:ajaxValidator ajaxListener="#{testBean.listenAjaxRequest}" event="onblur" reRender="myinputdiv" /> </h:inputText> </s:div>
then in managed beanpublic void listenAjaxRequest(AjaxEvent ajaxEvent) { HtmlBeanValidator beanValidator = (HtmlBeanValidator) ajaxEvent.getSource(); HtmlInputText htmlInputText = (HtmlInputText) beanValidator.getParent(); if (htmlInputText.isValid()) { htmlInputText.setStyleClass(null); } else { htmlInputText.setStyleClass("ierror"); } }
I could see the listener method is called as expected but somehow reRender is not working.
That means validation error message was shown but still input field remains without any style change.
Please help me to fix this. -
3. Re: Ajax Validator: Field Highlighting on validation error
ilya_shaikovsky Apr 3, 2009 6:31 AM (in response to techieexchange)need to check responce returned.
b.t.w. sorry.. there is much more easier way.. read about seam s:decorate.