1 Reply Latest reply on Nov 6, 2009 6:22 AM by Ilya Shaikovsky

    ComboBox vs. HotKey return

    peter koebele Newbie

      Hello everyone.

      Do you have any solution for the problem described below. If so, please let me know.


      I defined a form containing a combobox and several buttons. If the return key is pressed, on of the buttons shall be activated. For this I configured some rich:hotkeys as shown below. The return key shall also fire the form, if the combobox is focussed.
      Return key is captured by the combobox. Thus the form is not submitted, if the return key is pressed for a focussed combobox. Referring to your javascript combobox.js, you stop the event propagation in the filedKeyDownHandler() function.

      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1">
      <title>ComboBox vs. HotKey</title>
       <h:form id="TestHotKeyForm">
       <h:panelGrid columns="2">
       <h:outputLabel for="InputText" value="InputText" />
       <h:inputText id="InputText" value="#{testBackingBean.testEntity.stringValue}" />
       <h:outputLabel for="ComboBox" value="ComboBox" />
       <rich:comboBox id="ComboBox" converter="EnumConverter"
       suggestionValues="#{testBackingBean.allEnumValues}" />
       <h:commandButton id="CancelButton" value="Cancel" actionListener="#{testBackingBean.processEscape}" />
       <h:commandButton id="OkButton" value="OK" actionListener="#{testBackingBean.processEnter}" />
       <rich:hotKey key="esc" disableInInput="false"
       handler="#{rich:element('TestHotKeyForm:CancelButton')}.click()" />
       <rich:hotKey key="return" disableInInput="false"
       handler="#{rich:element('TestHotKeyForm:OkButton')}.click()" />