JSF

Multiple DefaultCommand in a form using different scopes in PrimeFaces

DefaultCommand in PrimeFaces is for specifying which clickable command in a form to trigger when ENTER key is pressed on an input in the form. It is especially useful when there are multiple commands in the form. Suppose that we have two Dialog in a form, and each has some inputs and a command button. Then two DefaultCommand can be defined so that when ENTER key is pressed on the inputs of either Dialog, the corresponding command button is triggered. If no DefaultCommand were defined, the first button with the type submit would always be triggered in most browsers.