8 Replies Latest reply on Apr 1, 2011 5:08 AM by langer123

    Backspace Hotkey not disabling in Richfaces Modal

    langer123

      Hi

      I have added the following to my pages (to prevent users been able to use the backspace function throughout the site):

      <rich:hotKey key="backspace" handler="return false;" disableInInput="true" />

      It works fine on the page that generates the popup modal, but when the modal is shown the hotkey will not work on the modal screen:

      <rich:modalPanel id="mpTest" minWidth="325" minHeight="225" zindex="2000">
      .....
      </rich:modalPanel>

      Do I need to do something differently for a modal screen?

        • 1. Re: Backspace Hotkey not disabling in Richfaces Modal
          lfryc

          Hello Thomas,

           

          what browser and what version of RichFaces do you use?

           

          I have tried on IE8 with RF 3.3.3.Final and it works also when modal shown:

           

          <h:inputText />
          <rich:hotKey key="backspace" handler="return false;" disableInInput="true" />
          
          <rich:modalPanel id="mpTest" minWidth="325" minHeight="225" zindex="2000" showWhenRendered="true">
            <h:inputText />
          </rich:modalPanel>
          
          
          • 2. Re: Backspace Hotkey not disabling in Richfaces Modal
            langer123

            HI Lucas

             

            I'm using Richfaces 3.3.3 and JSF 2.0.4.

            One thing i just noticed in the tomcat 7 console on startup is the following:

             

            INFO: Initializing Mojarra (1.2_15-b01-FCS) for context '/myApp'

             

            Does this mean that it's using JSF 1.2 for some reason?

             

            Thanks

            • 3. Re: Backspace Hotkey not disabling in Richfaces Modal
              lfryc

              Yes, it means you are using JSF 1.2:

               

              1. check what libraries do you have on classpath ${WAR}/WEB-INF/lib
              2. if you are using JBoss AS, it already provides JSF api and impl for you
                • you need to force it to use new version (overwrite JSF api and impl in server/default/deploy/jbossweb.sar/jsf-libs/

               

              Anyway the JSF impl should not influence the hotkey behavior, I will check though.

              • 4. Re: Backspace Hotkey not disabling in Richfaces Modal
                lfryc

                What browser are you using?

                • 5. Re: Backspace Hotkey not disabling in Richfaces Modal
                  langer123

                  Firefox 4 and IE8, same problem in both.

                  • 6. Re: Backspace Hotkey not disabling in Richfaces Modal
                    langer123

                    Ok. I've managed to narrow it down (I'm using with JSF 1.2 by the way)

                     

                    It seems that the problem happens when the modal opens for the first time. If you do not click/tab into it, pressing the backspace will return to previous page (Not behaviour I want).

                    If you click anywhere in the modal screen, and then select the backspace it works (Backspace disabled).

                     

                    So what I need is to give focus to some element in the modal screen. The only form element my modal screen has is a textarea that is readonly, so I do not want to set the focus in this.

                     

                    How can I set the focus on the modal screen?

                    The following does not seem to work (I think it might something to do with non-form elements not having a tab index and therefore not getting focus)

                     

                    <rich:hotKey key="backspace" handler="return false;" disableInInput="true" />

                     

                    <rich:modalPanel id="mpTest" minWidth="325" minHeight="225" zindex="2000" showWhenRendered="true" onshow="document.getElementById('mpTest').focus();">

                         <h:inputTextarea id="description" ....>

                    </rich:modalPanel>

                    • 7. Re: Backspace Hotkey not disabling in Richfaces Modal
                      lfryc

                      Since modal panel itself can't get focus, you can surely focus textArea:

                       

                      document.getElementById('description').focus();
                      


                      I have tried and it works for me

                      • 8. Backspace Hotkey not disabling in Richfaces Modal
                        langer123

                        I really dont want to set the focus in the text area. It is a readonly element and dont want a cursor there, with the user thinking they can add text.

                        Also, the backspace hotkey is still not disabled in IE8 when the focus is inside a modal readonly textarea (Works fine for firefox 4).

                         

                        Maybe this has become a different issue at this stage? (More related to javascript and html)