5 Replies Latest reply on Apr 1, 2011 7:20 PM by Waldo Nell

    s:selectItems calls value action too many times

    Waldo Nell Newbie

      I have logged an issue over at the RichFaces forum:


      http://community.jboss.org/message/596930


      After some troubleshooting it became evident my issue is not related to Ajax, but to Seam.  All the code and debug output is logged in that thread.  The basic problem is this:


      I have an XHTML page with a
       


      <h:selectManyListBox>
           <s:selectItems value="#{someActionMethod}" ...
        ...
      




      I also have this:




      <a4j:support event="onclick" action="#{advancedSearch.addField(set.val)}" reRender="advanced_search" requestDelay="0" ignoreDupResponses="true" />
      




      If, before I submit the form again, that first multi select listbox contains many items - say 500 - and I select ALL 500 entries, then when the a4j:support event is fired Seam seem to invoke the s:selectItems's value action method 500 times.  I.e., it invokes the action method as many times as I have selected entries in the list box.  If I have 500 entires in the list box but only select three, then it gets called three times before the response comes back.


      Why is this?

        • 1. Re: s:selectItems calls value action too many times
          Waldo Nell Newbie

          Maybe this helps.  this is the stack trace of the action listenr being called repeatedly:




          ...
                  at za.co.matrixmarketing.matrixweb.web.actions.AdvancedSearchAction_$$_javassist_seam_13.getLookupData(AdvancedSearchAction_$$_javassist_seam_13.java)
                  at sun.reflect.GeneratedMethodAccessor482.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:597)
                  at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
                  at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:280)
                  at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
                  at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
                  at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                  at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
                  at javax.faces.component.UISelectItems.getValue(UISelectItems.java:141)
                  at org.jboss.seam.ui.component.UISelectItems.getValue(UISelectItems.java:161)
                  at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:149)
                  at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:61)
                  at javax.faces.component.SelectUtils.matchValue(SelectUtils.java:82)
                  at javax.faces.component.UISelectMany.validateValue(UISelectMany.java:465)
                  at javax.faces.component.UIInput.validate(UIInput.java:875)
                  at javax.faces.component.UIInput.executeValidate(UIInput.java:1072)
                  at javax.faces.component.UIInput.processValidators(UIInput.java:672)
                  at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
                  at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
                  at com.sun.facelets.component.UIRepeat.process(UIRepeat.java:366)
                  at com.sun.facelets.component.UIRepeat.processValidators(UIRepeat.java:447)
                  at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
                  at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
                  at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
                  at org.ajax4jsf.component.UIAjaxRegion.processValidators(UIAjaxRegion.java:121)
                  at org.ajax4jsf.component.AjaxViewRoot$3.invokeContextCallback(AjaxViewRoot.java:447)
                  at org.ajax4jsf.component.ContextCallbackWrapper.invokeContextCallback(ContextCallbackWrapper.java:44)
                  at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:711)
                  at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
          ...
          



          • 2. Re: s:selectItems calls value action too many times
            Martin Frey Newbie

            If i interpret it correctly you have an onclick event on each selectitem. Are you sure that this is what you want? Most probably you need the onchange or onblur event on the selectmanyListbox. This will happen only once or per change.


            I dont think this has anything special to do with seam. It's normal web behavior If my assumption is correct.

            • 3. Re: s:selectItems calls value action too many times
              Waldo Nell Newbie

              Nope.  They are separate things, there is no onclick event handler in the select items.  The onclick is in another piece of code elsewhere on the page.

              • 4. Re: s:selectItems calls value action too many times
                Martin Frey Newbie

                Then i don't get where this aj4 support is attached to. What happens if you remove it and use just a command button to submit the page? Do you have the same problem?


                I've created a test case with 20 selectboxes with around 20'000 selectitems for testing the s:convertentity tag and i was able to get a continued response time of around 8 sec.


                - http://seamframework.org/Community/NewEntityConverterPOC


                Have you tried to use only String values as selectitems? Like this you can probably drill down the problem to be either a hibernate or a seam issue?

                • 5. Re: s:selectItems calls value action too many times
                  Waldo Nell Newbie
                  I removed any a4j:region tags, and then used another link I have outside of that select items control that posts to the same form:

                  <h:column>
                    <div class="remove_link"><h:commandLink action="#{advancedSearch.removeSearchConditionEntry(sc)}"  ><img src="images/ui/remove_icon.png" alt="Remove" /></h:commandLink></div>
                  </h:column>

                  As you can see, it does perform validations.  It causes the exact same behaviour - the lookupData call gets called once for every selected item.  So this rules out Ajax as having any influence on this issue.

                  I am working on your other ideas.  Thanks for your assistance so far.