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

    ComboBox vs. HotKey return

    pkx

      Hello everyone.

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

      Regards
      pkx

      Intention:
      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.
      Problem:
      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.
      Example:

      <%@ 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"
       pageEncoding="ISO-8859-1"%>
      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1">
      <title>ComboBox vs. HotKey</title>
      </head>
      <body>
      <f:view>
       <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"
       value="#{testBackingBean.testEntity.enumValue}"
       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()" />
       </h:panelGrid>
       </h:form>
      </f:view>
      </body>
      </html>
      


        • 1. Re: ComboBox vs. HotKey return
          ilya_shaikovsky

          please rise jira issue on that. It done in this way because if you trying to choose something from the list by pressing ENTER - form will be submitting instead. We could try to check for some other solution.