9 Replies Latest reply on Jan 22, 2008 9:50 PM by tony.herstell1

    Spinner pressed quickly a few times causes problems in Seam.

    tony.herstell1

      This code:

      <rich:inputNumberSpinner id="mealsPerSittingNumber" immediate="true"
       enableManualInput="false" minValue="10" maxValue="100" step="1"
       rendered="#{eachResource == 'CATERING_PER_HEAD'}" value="#{bookingController.cateringMealsPerSittingNumber}">
       Meals per sitting
       <a4j:support event="onchange" LimitToList="true" reRender="resourcesAddedTotal" RequestDelay="2000"/>
      </rich:inputNumberSpinner>
      


      When I press the spinner button quite quickly then I have problems n Seam.

      The conversation seems to be killed and I end up back at the Home page.

      I added RequestDelay="2000" in the hope that that would stop the requests going too quickly but I see through Firebug that the requests all go really quick.

      Am I missing something?

        • 1. Re: Spinner pressed quickly a few times causes problems in S

          define eventsQueue attribute for a4j:support

          Read "Queue and Traffic Flood Protection" section at: http://livedemo.exadel.com/richfaces-demo/richfaces/ajaxAttributes.jsf?c=ajaxattributes

          • 2. Re: Spinner pressed quickly a few times causes problems in S
            tony.herstell1

            Thanks Sergey...

            • 3. Re: Spinner pressed quickly a few times causes problems in S
              tony.herstell1

              Can you see anything wrong with this as the queue param seems to have not changed anything.

              <rich:inputNumberSpinner id="stableNumbers" immediate="true" enableManualInput="false" minValue="1" maxValue="25" step="1"
               rendered="#{eachResource == 'INDOOR_STABLE'}" value="#{bookingController.stableNumbers}">
               <a4j:support event="onchange" LimitToList="true" reRender="resourcesAddedTotal" eventsQueue="stableNumbersQueue"/>
              </rich:inputNumberSpinner>
              


              I read teh doco and can't see a problem.

              Am using 3.1.2.SP1 righ tnow (upgrading later today I hope!)


              • 4. Re: Spinner pressed quickly a few times causes problems in S
                tony.herstell1

                Humm RTFM .. I took out the requestDelay. Silly me!

                • 5. Re: Spinner pressed quickly a few times causes problems in S
                  • 6. Re: Spinner pressed quickly a few times causes problems in S
                    tony.herstell1

                    Ok, I have to admit I am not sure what all that means.. you must have me mistaken with someone who really understands all this ;)

                    I think what it is saying is that since some server side vars don't get updated till one of the late stages of the JSF lifecycle then I ain't going to be able to use em as they wont be updated in time.

                    I think I just cheated and made them immediate=true to force the server side vars to be updated earlier in the phases. This works in all my problem cases so far ;)

                    This looks like the PROPER way to do things.. I think!

                    • 7. Re: Spinner pressed quickly a few times causes problems in S

                      The last link was not about the queue or immediate , actually.

                      You have: rendered="#{eachResource == 'INDOOR_STABLE'}"

                      if this condition is false at the beginning of the 2nd phase, the event from the a4j:support will not be processed.
                      It is just a hidden stone in your code.

                      • 8. Re: Spinner pressed quickly a few times causes problems in S
                        tony.herstell1

                        This is the code block and it all seems to work ok... I can't see any problems...

                        The 'XXXXX' is from an enum and its pretty cool that if I mis-spell it then I actually get an error as SOMETHING somehwere is actually mapping it to the ENUM within the El (I think)!.. VooDoo!

                        bookingResources is made available to the view by

                        @DataModel
                        private List<ResourceKind> bookingResources;
                        


                        <rich:column colspan="3" breakBefore="true" rendered="#{eachResource == 'YARD' || eachResource == 'INDOOR_STABLE' || eachResource == 'CATERING_PER_HEAD'}">
                         <rich:inputNumberSpinner id="yardNumbers" immediate="true" enableManualInput="false" minValue="1" maxValue="25" step="1" rendered="#{eachResource == 'YARD'}" value="#{bookingController.yardNumbers}">
                         <a4j:support event="onchange" LimitToList="true" reRender="resourcesAddedTotal" eventsQueue="yardNumbersQueue" requestDelay="2000"/>
                         </rich:inputNumberSpinner>
                         <rich:inputNumberSpinner id="stableNumbers" immediate="true" enableManualInput="false" minValue="1" maxValue="25" step="1" rendered="#{eachResource == 'INDOOR_STABLE'}" value="#{bookingController.stableNumbers}">
                         <a4j:support event="onchange" LimitToList="true" reRender="resourcesAddedTotal" eventsQueue="stableNumbersQueue" requestDelay="2000"/>
                         </rich:inputNumberSpinner>
                         <rich:inputNumberSpinner id="sittingsNumber" immediate="true" enableManualInput="false" minValue="1" maxValue="15" step="1" rendered="#{eachResource == 'CATERING_PER_HEAD'}" value="#{bookingController.cateringSittingsNumber}"><h:outputText value="#{messages.book_catering_sittings}"/>
                         <a4j:support event="onchange" LimitToList="true" reRender="resourcesAddedTotal" eventsQueue="sittingsNumberQueue" requestDelay="2000"/>
                         </rich:inputNumberSpinner>
                         <rich:inputNumberSpinner id="mealsPerSittingNumber" immediate="true" enableManualInput="false" minValue="10" maxValue="100" step="1" rendered="#{eachResource == 'CATERING_PER_HEAD'}" value="#{bookingController.cateringMealsPerSittingNumber}"><h:outputText value="#{messages.book_catering_meals_per_sitting}"/>
                         <a4j:support event="onchange" LimitToList="true" reRender="resourcesAddedTotal" eventsQueue="mealsPerSittingNumberQueue" requestDelay="2000"/>
                         </rich:inputNumberSpinner>
                        </rich:column>
                        


                         public enum ResourceKind {
                         RESIDENT_TRAINER ("resource_resident_trainer"),
                         INDOOR_ARENA ("resource_indoor_arena"),
                         DRESSAGE_ARENA ("resource_dressage_arena"),
                         SJ_ARENA ("resource_sj_arena"),
                         DRESSAGE_BOARDS_LETTER ("resource_dressage_boards_letters"),
                         SHOWJUMPS ("resource_showjumps"),
                         TIMING_EQUIPTMENT ("resource_timing_equiptment"),
                         PA_SYSTEM ("resource_pa_system"),
                         YARD ("resource_yard"),
                         INDOOR_STABLE ("resource_indoor_stable"),
                         CAFE ("resource_cafe"),
                         CONF_ROOM ("resource_conf_room"),
                         BOARDROOM ("resource_boardroom"),
                         CATERING_PER_HEAD ("resource_catering_per_head"),
                         EVENTS_MANAGEMENT_SOFTWARE ("resource_events_management_software");
                         private final String inlLabel;
                         ResourceKind(String inlLabel) {
                         this.inlLabel = inlLabel;
                         }
                         public String getInlLabel() { return inlLabel; }
                         }
                        


                        • 9. Re: Spinner pressed quickly a few times causes problems in S
                          tony.herstell1

                          I think the spinner is not even rendered anyhow so the event can't be raised anyhow.