4 Replies Latest reply on Nov 6, 2008 12:42 PM by Jason Long

    rich:hotKey with rich:datascroller

    Jason Long Master

      I just tried

      <a4j:jsFunction name="defaultPipeSearch" action="#{listPipeSearch.search}" reRender="pipeSearchTabPanel" status="commonstatus0"/>
       <rich:hotKey key="ctrl+s" handler="defaultPipeSearch();return false;"/>


      I just tried this and it rocks. It even overrides Firefox's built in hot keys.

      What is the best way to tie this to rich:datascroller?

      <rich:hotKey key="ctrl+left" handler="how do I click < with javascript?;return false;"/>
       <rich:hotKey key="ctrl+alt+left" handler="how do I click << with javascript?;return false;"/>
       <rich:hotKey key="ctrl+right" handler="how do I click > with javascript?;return false;"/>
       <rich:hotKey key="ctrl+alt+left" handler="how do I click >> with javascript?;return false;"/>


        • 1. Re: rich:hotKey with rich:datascroller
          Nick Belaevski Master

          Hi,

          There's no JS API, so I've created an issue to implement it: https://jira.jboss.org/jira/browse/RF-4870

          The following can serve as a workaround:

          Event.fire(#{rich:element('scrollerId')}, 'rich:datascroller:onscroll', {'page': '7'});


          You can use: 'first', 'fastrewind','previous','next','fastforward','last' or numeric value as page.

          • 2. Re: rich:hotKey with rich:datascroller
            Martin Dubuc Newbie

            I have tried the recommended workaround:

            Event.fire(#{rich:element('scrollerId')}, 'rich:datascroller:onscroll', {'page': '7'});

            I can see the scroller page is changed internally (in this case to page 7). However, the page is not refreshed and still display the original page. I have to reload the current page for the change to be visible. There is no reRender attribute for the rich:hotKey. I have tried to add a a4j:jsFunction and invoke it from the rich:hotKey, but even though I specify the data scroller id in the reRender property, the page isn't refreshed. Also, I can't put a #{...} expression in the action property of a4j:jsFunction. The application (running inside Tomcat) throws the following exception:
            #{..} is not allowed in template text

            • 3. Re: rich:hotKey with rich:datascroller
              Jason Long Master

              My code below works perfectly for me.

              Note: if you want to use multiple keys i.e. ctrl+alt+left, this must be in alphabetical order as alt+ctrl+left

              See http://code.google.com/p/js-hotkeys/wiki/about

              <rich:datascroller id="pipeSearchDatascroller"
               binding="#{datascrollerUI.datascroller}"
               for="pipeSearchDataTable"
               reRender="pipeSearchDataTotals"
               status="commonstatus0"/>
              
               <rich:hotKey key="ctrl+left"
               handler="Event.fire(#{rich:element('pipeSearchDatascroller')}, 'rich:datascroller:onscroll', {'page': 'previous'});;return false;"/>
               <rich:hotKey key="alt+ctrl+left"
               handler="Event.fire(#{rich:element('pipeSearchDatascroller')}, 'rich:datascroller:onscroll', {'page': 'first'});;return false;"/>
               <rich:hotKey key="ctrl+right"
               handler="Event.fire(#{rich:element('pipeSearchDatascroller')}, 'rich:datascroller:onscroll', {'page': 'next'});;return false;"/>
               <rich:hotKey key="alt+ctrl+right"
               handler="Event.fire(#{rich:element('pipeSearchDatascroller')}, 'rich:datascroller:onscroll', {'page': 'last'});;return false;"/>


              • 4. Re: rich:hotKey with rich:datascroller
                Jason Long Master

                Maybe this should be built in with some defaults.

                <rich:datascroller hotKeyNav="true"/>

                Would do the equivalent of the 4 a4j:hotKey I assigned.

                You could override the default by

                <rich:datascroller hotKeyNav="true" firstKey="ctrl+down" lastKey="ctrl+up"/>


                I am going to do this with a facelets template for now, but this would be nice out of the box.