-
1. Re: setting focus back to current input control after validation error
ilya_shaikovsky Jan 21, 2010 5:43 AM (in response to asookazian)you could:
1) point focus attribute of support to some bean property which will holds the id of the component to be focused.
2) write ajaxListener which will be invoked before renderResponce(so, it's fired even when validation errors occured). In the listener check if there was validation/conversion errors in added Faces Context. And if there are any pick the first message and put the id of the component which was risen this error to the property from 1) point.
So if the focus attribute will remain empty - nothing will be changed for the user. And if it's contains id - this component thrown vaildation message and focus should be set to it.
-
2. Re: setting focus back to current input control after validation error
asookazian Jan 21, 2010 11:02 AM (in response to ilya_shaikovsky)How do you set focus to a component that is rendered multiple times in multiple rows of a dataTable (this is actually the case here)?
i.e. I have multiple rich:calendar controls that need the same validation and focus set to that one which failed validation.
-
3. Re: setting focus back to current input control after validation error
ealonso04 Jun 21, 2012 5:42 PM (in response to asookazian)Hi guys!
I have the same issue right now! Did you find the solution to this?
I almost understand the idea of Ilya but I don't know how to tell directly to the input control to obtain the focus, I mean, do I have to do that inside the java class where Im catching the listener and checking the FacesMessages, in order to know if there was at least one message error?
Or is there a way to do that inside the xhtml file by some tag?
I hope you can help out with this. Thanks in advance!