ComboBox vs. HotKey return
pkx Nov 5, 2009 8:59 AMHello 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>