Question

In our JSF web application, we have an input field where the user can enter a numeric ID, which is then looked up by the app. To help the user, the lookup is bound to "onchange", thus it will be triggered as soon as the user tabs out of the field or clicks elsewhere.

So, user enters "123", presses tab (or clicks), lookup runs. This works fine; however, for usability reasons, we also want to provide a button that users can click on, for users who will otherwise wonder "where should I click to trigger a lookup?". To do this, we'd like to provide something that looks and feels like a HTML / JSF button, but does nothing (as the click will trigger the "onchange" event anyway).

Is there a way to make a JSF button that does nothing? I tried using h:commandButton without the "action" attribute, but it still fires a request.

Was it helpful?

Solution

p:commandButton type="button" will just provide a push button.

OTHER TIPS

Since you tagged this question also as a usability issue, I would advise against a button in the first place if the onchange already triggers the lookup.

From a user's perspective it is confusing whether or not clicking the button is mandatory. After they have entered the field and skipped to the next, they see the lookup occur without clicking the button. If there is a button they will assume it's there for a reason.

The option that I favour in these cases is a onkeypress handler with a timeout of half a second, after which the value is looked up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top