Page 1 of 1

p:commandButton get executed when explicitly focused

Posted: 06 Feb 2011, 01:41
by evillalona
Please i need some help on focus controlling without the p:focus component. Im doing it pretty well with javascript
function setfocus(a_field_id) {
jQuery(PrimeFaces.escapeClientId(a_field_id)).focus();
}
or
function setfocus2(a_field_id) {
document.getElementById(a_field_id).focus;
}
Except with p:commandButton. When i explicitly set the focus in this line: <h:inputText id="itText" onkeypress="setfocus('frMain:cbCreate');"/> to a commandButton like this:
<p:panel id="paButtons">
<p:commandButton value="Create" ajax="true" id="cbCreate" actionListener="#{buttonsBean.buttonsActions}" disabled="#{!buttonsBean.btnCreate}" update="frMain:paButtons">
<f:param id="prCreate" name="btnOption" value="Create"/>
</p:commandButton>
</p:panel>

the commandButton get executed and i just want it focused.
Any help will be appreciated.