3
votes

I have an easy question.

I have few primefaces inputtext and two primefaces commandbutton on my xhtml page. When I press enter after edited the inputtext, it triggers one of my commandbutton.

But I want to trigger the other commandbutton. How to do that? And how it decide which commandbutton is to be triggered? What is the reason there?

Thanks for help.

2

2 Answers

3
votes

You can use p:defaultCommand

<p:defaultCommand target="btnId" />
1
votes

You can catch the "press enter event" in JavaScript and simulate a click on the button of your choice.

Something like this :

$('#yourInput').on('keyup', function(e) {
    if (e.which == 13) {
        $("#yourButton").click();
    }
});