Good Afternoon,
Using JSF + Primefaces. I have a dataTable with inputText field, which performs a listner, and when you end the function or pressing tab, the focus would be to input the low line of the same component.
Googled some things, and it seems that's to be done with JavaScript or jQuery, but I have not much knowledge.
It seems that the clientId of the component has something form: dataTable: 0: input, and the number "0" to manipulate the focus. Anyone know how to work the focus of components within the dataTable?
Thank you.
You could use the PrimeFaces element <p:focus />
, and in the "context" attribute, put the ID of the dataTable. The "context" attribute serves to set the root component to start first input search, so if you are using AJAX, you could update the container where the "dataTable" and the "focus" elements are wrapped, and the first input in the dataTable will recieve the focus after AJAX call:
<p:focus context="dataTable" />
You could use the "for" attribute too, if you want to refer the input directly:
<p:focus for="inputText" />
Take a look to the PrimeFaces documentation: p:focus.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With