Since 3.3
You can use the icecore:defaultAction tag to initiate a form submit when a certain key is pressed. An action or an action listener can be defined to control which method to be invoked on the server side.
To use the icecore:defaultAction tag, first declare the core namespace:
<html ... xmlns:icecore="http://www.icefaces.org/icefaces/core">
Then add the tag to your page markup wiring the action to the bean method:
<h:form id="form">
...
<icecore:defaultAction actionListener="#{sampleBean.update}" key="Enter"/>
...
</h:form>
The component can be used within a form to capture certain key press events. Multiple icecore:defaultAction instances can be used to capture different key press events.
<h:form id="form">
...
<icecore:defaultAction actionListener="#{sampleBean.update}" key="Enter"/>
<icecore:defaultAction action="#{sampleBean.cancel}" key="Esc"/>
<icecore:defaultAction action="#{helpBean.help}" key="F1"/>
...
</h:form>
Multiple key mappings wired to the same action/actionListener can be done as well.
<h:form id="form">
...
<icecore:defaultAction actionListener="#{sampleBean.update}" key="Enter"/>
<icecore:defaultAction actionListener="#{sampleBean.update}" key="Esc"/>
<icecore:defaultAction actionListener="#{sampleBean.update}" key="LeftArrow"/>
...
</h:form>
TagLib Documentation
This section covers attributes involved in the typical use-cases for this component.
key Use this attribute to specify the key-press that should be used for triggering the submit. The following predefined key names can be used: "Enter", "Esc", "Space", "PageUp", "PageDown", "PageUp", "LeftArrow", "UpArrow", "RightArrow", "DownArrow", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12".
action Use this attribute to reference a bean method. The method is invoked when the defined key is pressed and no other component within the form doesn't capture the fired event.
actionListener Use this attribute to reference a bean method. The method is invoked when the defined key is pressed and no other component within the form doesn't capture the fired event.