Technology: ADF11g
Developed in: JDeveloper 11.1.1.3.0
Browsers tested: Firefox 3.6.13 and Internet explorer 7 (7.0.6002.18005)
Used database schema: HR
Used tables: EMPLOYEES
Summary
In this blog a solution is provided how to trigger an action on enter. An action can be a command link or button. All defined actions (action, actionListener, showPopupBehaviour) will be executed when the user uses the enter.
To trigger an action set the defaultCommand property of the af:form tag. Set the value to the ID of the button / link that should be triggered on action.
We’ll use the following page in this blog:

This page is based on the EMPLOYEES table in the HR schema. The table is created by drag and drop from the Data control palette. An edit (commandLink) column is added to navigate to a form of the employee. The page contains 2 buttons, a Cancel which navigates back to the home page and create an insert which creates a now employee row and navigates to the form.
Trigger a button
In this example we’ll trigger the Cancel button, the cancel button asks for confirmation and if the user answers with OK it navigates back to the home page.
The button looks like this:
<af:commandButton text="Cancel"
id="cancel"
immediate="true">
<af:resetActionListener/>
<af:showPopupBehavior popupId="cancelPopup"
triggerType="action"/>
</af:commandButton>
<af:form id="f1">
<af:form id="f1" defaultCommand="pt1:cancel">
When we run this and we press enter you get:

Trigger a link
In this example we’ll trigger the Edit command link, the link contains an actionListener which adds an information message to the stack and an action which navigates to the form.
First set the current row of the view object by selecting a row:

Then when enter is pressed:

The commandLink for this example looks like this:
<af:column headerText="Edit employee"
id="c12">
<af:commandLink text="Edit"
id="cl5"
actionListener="#{employeeBean.edit}"
action="edit"/>
</af:column>
<af:form id="f1" defaultCommand="pt1:t1:cl5">
The employeeBean refers to a request scoped bean that contains an edit method:
public void edit(ActionEvent actionEvent) {
EmployeesViewImpl view = getService().getEmployeesView();
String name = view.getCurrentRow().getAttribute("FirstName") + " " + view.getCurrentRow().getAttribute("LastName");
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Edit", "Edit person: " + name.trim()));
}
private static HrAppModuleImpl getService() {
DCBindingContainer bc = (DCBindingContainer)FacesContext.getCurrentInstance().getApplication().evaluateExpressionGet(FacesContext.getCurrentInstance(), "#{bindings}", BindingContainer.class);
DCDataControl dc = bc.findDataControl("HrAppModuleDataControl");
return (HrAppModuleImpl) dc.getDataProvider();
}