Primefaces, JavaScript, and JSF does not work well together or am I doing something wrong
Posted
by
Harry Pham
on Stack Overflow
See other posts from Stack Overflow
or by Harry Pham
Published on 2010-10-27T23:08:21Z
Indexed on
2011/01/17
1:53 UTC
Read the original article
Hit count: 672
Here is something so simple
<p:commandLink value="Tom" onclick="document.getElementById('tom').focus()"/><br/>
<input id="tom"/>
When u click on the Tom, the textbox get focus. Great, now try this
<p:commandLink value="Tom" onclick="document.getElementById('tom').focus()"/><br/>
<h:inputText id="tom"/> <br/>
when I click nothing happen, I check firebug, I see
document.getElementById("tom") is null
When I try to use jQuery $('#tom').focus()
, nothing happen, no error, but did not get focus either. This is the response
(not sure if this is the response from the server) when I see from firebug
<?xml version="1.0" encoding="utf-8"?>
<partial-response>
<changes>
<update id="javax.faces.ViewState"><![CDATA[455334589763307998:-2971181471269134244]]></update>
</changes>
<extension primefacesCallbackParam="validationFailed">{"validationFailed":false}</extension>
</partial-response>
© Stack Overflow or respective owner