why rich:hotKey not worked when using jQuery?
eswaramoorthy1985 Jun 11, 2010 4:00 AMHi,
I use rich:hotkey, at the same time just load jQuery.
Case 1 : If not load jquery.js
:
After set cursor focus textfield, i hit enter(Keyboard) button from that textfield,
then automatically called alert (ok button click event) window.
Case 2 : If load jquery.js
:
The first case not worked.
Some times, If hit enter button from textField, that time page will be refreshed.(Not often, rare case).
<%@page contentType="text/html" pageEncoding="UTF-8"%>
i set rich:hotKey(name field) for OK button.
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<a4j:loadScript src="resource://jquery.js"/>
<script type="text/javascript">
function okClicked()
{
alert("Ok Button Clicked");
}
</script>
</head>
<body onload="document.getElementById('includedForm:nameField').focus();">
<h:form id="includedForm">
<rich:panel id="includedPanel">
<h:panelGrid columns="2">
<h:outputText value="Name : " />
<h:inputText id="nameField" styleClass="nameField" value ="" />
<a4j:commandButton id="okButton" value="Ok" onclick="okClicked();" focus="okButton"/>
<a4j:commandButton id="cancelButton" value="Cancel" />
<%--HotKey for nameField --%>
<rich:hotKey key="return"
selector="#nameField"
handler="#{rich:element('okButton')}.click();
event.stopPropagation();event.preventDefault();
return false;"/>
</h:panelGrid>
</rich:panel>
</h:form>
</body>
</html>
</f:view>
Help me about this.
Thanks in advance.