Is it possible to fire action,actionListener of a <p:commandButton>
with attribute type="button"
. I have a requirement where in a form there are text boxes and command buttons. If I press enter in any text box then commandButton
is invoked. So I change all command buttons type to "button". Now problem I am facing that command button's action, actionListener not firing.I want to solve it with out using java script. Also I read this This Link. Can any one tell me where I should edit or change to get expected output. Thanks.
<p:commandButton>'s action listener not firing with attribute type="button"
1.1k Views Asked by Diganta At
1
Using
type="button"
is the wrong solution to prevent enter key from submitting the form. It basically changes the submit button to a dead button which does not submit the form and is only useful for attaching JavaScriptonclick
and likes. You're simply facing the consequences of this wrong solution. You should not try to fix it, but take a step back and solve the initial problem the right way.One of the ways is:
Or, more generically, with jQuery, which skips textareas from the restriction:
Note: jQuery is already bundled in PrimeFaces, you do not need to install any scripts separately. Also note that you really can't go around JavaScript here. Even more, PrimeFaces/ajax components rely on JavaScript and wouldn't work anyway without JavaScript.