Controlling form submission using defaultCommand

The Enter key makes form submission so easy that users always tend to use it. The most intuitive way is that the user can enter some text or make some changes to the existing text and then hit the Enter key to submit the form. But what command component will submit the form if we have more than one of them? Browsers, especially Internet Explorer, behave differently here. The defaultCommand component solves this problem by normalizing the command (for example, button or link) that submits the form when the Enter key is hit.

In this recipe, we will discuss p:defaultCommand in detail. We will implement p:selectOneMenu for dynamic selection of the command button used for form submission when the Enter ...

Get PrimeFaces Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.