4 Replies Latest reply on Aug 17, 2012 12:30 PM by dmalmeida

    Problems with richfaces:hotkey

    dmalmeida

      Hello,

       

      I have problems using the hotkey component as shown in the showcase page. I'm trying to detect when the user hit the enter key and perform a specific action on a input textbox. The code I used as an example is:

       

      <h:inputText id="txtCodigo" value="#{anularFacilidadControlador.codObligacion}"                                                            
                       <rich:hotKey selector="#txtCodigo" key="return">
                                <rich:componentControl event="blur" target="popup" operation="show" />
                     </rich:hotKey>
       </h:inputText>
      
      
      

       

      The code is trying to open a rich:popupPanel when the user press return, but nothing happens. In fact the behaviour related with rich:componentControl is disabled.

       

      I noticed that in the richfaces showcase, the hotkey component generates a script with new RichFaces.ui.HotKey, but in my page, nothing happens. Only two js scripts are imported: hotkey.js and jquery.hotkeys.js

       

      Thank you in advance for your help.

        • 1. Re: Problems with richfaces:hotkey
          lfryc

          Hey Diego,

           

          have you tried to place rich:hotKey outside of h:inputText.

           

          I have doubts that new RichFaces.ui.HotKey contructor is called before txtCodigo input text element.

           

           

          Also, can you see any feedback on developer console?

          • 2. Re: Problems with richfaces:hotkey
            dmalmeida

            Hi Lukáš,

             

            I've tried to use the hotkey component like the following snippet:

             

             

             <h:body>
                    <h:form id="aForm">
                        Hello from Facelets
                        <rich:hotKey selector="#aForm" key="backspace" preventDefault="true" enabledInInput="false"/>
                    </h:form>
            </h:body>
            
            

             

            And the constructor generates, but I think it's incomplete. This is the generated code for the constructor:

             

             

            new RichFaces.ui.HotKey("aForm:j_idt8",  {"key":"backspace","selector":"#aForm"} );
            
            

             

            But in the showcase, the generated code, includes something like this:

             

             

            new RichFaces.ui.HotKey("j_idt239:j_idt243",  {"key":"right","selector":"#j_idt239\\:pickList","onkeydown":function(event){RichFaces.ui.ComponentControl.execute(event,{"selector":null,"target":["j_idt239:pickList"] ,"callback":function(event,component){component['add'].apply(component,[] );}} ); return false;}} );
            
            

             

            Am I missing something?

             

            Btw, I am ussing RF 4.2.2.Final with Jboss 6 EAP.

            • 3. Re: Problems with richfaces:hotkey
              ppitonak

              Hi Diego,

               

              I managed to open a popup panel when user presses the enter key. The following code worked for me:

               

              <h:form id="form">
              
                  <h:inputText id="txtCodigo" value="first input"/>
              
                  <rich:hotKey id="richHotKey" enabledInInput="true" key="return" onkeyup="#{rich:component('popupPanel')}.show()" preventDefault="true" selector="#txtCodigo" />
              
                  <rich:popupPanel id="popupPanel" header="my popup panel">content of popup panel</rich:popupPanel>
              
              </form>
              
              

               

              Using component control is too complicated when you can open a popup panel using its public API.

               

              Regards,

              Palo

              • 4. Re: Problems with richfaces:hotkey
                dmalmeida

                Thanks Pavol!

                 

                It was neccesary to add the attribute onkeyup in order to complete the contructor that generates Richfaces on javascript.

                 

                Regards

                DieGo