tags:

views:

45

answers:

1

I have a requirement where clicking each errors should focus input box. I am trying different ways but could not succeed. I got some answers in the past but that did not work like i wanted.

I was using tag with onclick event but I had to do this for each input boxes which is not so relevant if I have 20 fields. So I was looking some thing dynamic .for eg: .

Its has been a long I am looking for this solution. Any kind of help or suggestions would be highly appreciated.

+1  A: 

Can you consider this -> Instead of showing all the error messages on top, you can show the error message along with the input box which is related to this input box. The h:message have a attribute for which you can use.

Other option would be developing custom renderer which will output onclick event for each error message. The error message have the component id so you can use that id to set the focus in javascript. This will be all dynamic.

Here is some information about implementing custom renderer http://java.sun.com/javaee/javaserverfaces/reference/docs/customRenderKit.html

Bhushan