jQuery not support rich:hotKey in jsf tag

Posted by eswaramoorthy-nec on Stack Overflow See other posts from Stack Overflow or by eswaramoorthy-nec
Published on 2010-05-26T05:34:08Z Indexed on 2010/05/26 5:41 UTC
Read the original article Hit count: 327

Filed under:
|
|
|

Hi,

i have used rich:hotKey for h:inputText in my jsp page.

And also i wrote jQuery for get the textBox value.

When i use jquery, that time rich:kotKey not worked

sample.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ 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">

<html>
<f:view>
    <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
         <title>JSP Page</title>
         <script type="text/javascript" src="../../resource/js/jquery.min.js"/>
         <script type="text/javascript"> 
             function typedName()
             {
                  //Get The value using styleClass id
                  var userName = jQuery.trim($('.textBox').val());
                  alert("Name is : " + userName);
             }

             // If i am not use above typedName() script and load src, then
             // the following testButton() clicked script perfectly worked.

             function testButton()
             {
                  alert("Test Button Clicked");
             }
          </script>
</head>
<body>

<h:form>
    <rich:panel>

          <h:outputText value="Enter your Name : "/>
          <h:inputText id="textBox" styleClass="textBox" value ="" />&nbsp;

          <a4j:commandButton id="nameButton" value="NameButton" 
                             onclick="typedName();"/><br>

          <a4j:commandButton id="testButton" value="TestButton" 
                             onclick="testButton();" />

           <%--HotKey for text Box and focus to testButton --%>
           <rich:hotKey key="return"
                        selector="#textBox"
                        handler="#{rich:element('testButton')}.click();
                        event.stopPropagation();event.preventDefault();
                        return false;"/>
       </rich:panel>
     </h:form>
   </body>   
</f:view>

If i am not include the jquery, then that time i hit the enter button from text box, then automatically called testButton() script.

If i include the Jquery, then rich:hotkey not work.

I am also Used , var $J = jQuery.noConflict(); . But this time also not work jQuery.

I hope help me about this.

Thanks for your effort.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery