June 21, 2013

Defining default action to button in ADF



There are many cases where user wants to submit a page or form on press of “Enter”  key.
ADF provides a direct solution to this.
af:form or af:subform has a property called defaultCommand.
If we give button id as its value then on press of enter key, the given button will be executed.

Example:

<af:subform defaultCommand="cb1" id="s2">
  <af:panelFormLayout id="pfl1">   
    <af:inputText label="User Name" id="it1" />
    <af:inputText label="Password" id="it2" secret="true"/>
    <af:commandButton text="Login" id="cb1"  action="#{pageFlowScope.mbean.doLogin}" />
  </af:panelFormLayout>
  </af:subform>

No comments:

Post a Comment