7 Replies Latest reply on Nov 4, 2009 9:05 AM by Alexey Borschenko

    a4j:support fires event twice; and second time it passes wro

    Alexey Borschenko Newbie

      I'm trying to create linked comboboxes: one for selecting country and another for states.

      <h:selectOneMenu value="#{flowScope.countryId}">
       <f:selectItem itemLabel="---" itemValue="#{null}"/>
       <f:selectItems value="#{countrySelectItems}"/>
       <a4j:support event="onchange"
       action="countrySelected"
       ignoreDupResponses="true"/>
       </h:selectOneMenu>


      when I select country in list, I see in logs 2 records:
      1. countryId passed with correct value
      2. countryId passed with empty '0' value

      HEEEEEEEEEEEEEEEELP!

        • 1. Re: a4j:support fires event twice; and second time it passes
          Alexey Borschenko Newbie

          the summary is:

          a4j:support submits twice and 2nd time wrong value is submitted :(((((

          • 2. Re: a4j:support fires event twice; and second time it passes
            Paul Pantages Novice

            Hello U268, I am not certain what is wrong.
            But the action looks a bit funny to me. Shouldn't it be something like

            "#{somebean.countrySelected}"

            • 3. Re: a4j:support fires event twice; and second time it passes
              Ilya Shaikovsky Master

              a4j:support encoded as just ajax framework method call in the components event attribute. You could easily check it in generated HTML. So it can't made two submits if the component itself do not call event twice.

              • 4. Re: a4j:support fires event twice; and second time it passes
                Nick Belaevski Master

                Please use PhaseTracker and check if there are actually two requests.

                • 5. Re: a4j:support fires event twice; and second time it passes
                  Alexey Borschenko Newbie

                  Here is server log:

                  2009-11-03 19:39:29,727 TRACE [org.springframework.web.context.support.XmlWebApplicationContext] - Publishing event in context [org.springframework.web.context.support.XmlWebApplicationContext@343bb6]: org.springframework.security.access.event.AuthorizedEvent[source=FilterInvocation: URL: /flow/customerWizard?execution=e2s1]
                  2009-11-03 19:39:29,727 DEBUG [org.springframework.web.filter.RequestContextFilter] - Bound request context to thread: org.springframework.security.web.wrapper.SecurityContextHolderAwareRequestWrapper@1e39819
                  2009-11-03 19:39:29,730 TRACE [org.springframework.web.servlet.DispatcherServlet] - Bound request context to thread: org.springframework.security.web.wrapper.SecurityContextHolderAwareRequestWrapper@1e39819
                  2009-11-03 19:39:29,730 DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'WEB FLOW' processing POST request for [/PanoshopEngine/flow/customerWizard]
                  2009-11-03 19:39:29,730 TRACE [org.springframework.web.servlet.DispatcherServlet] - Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping@15f9d52] in DispatcherServlet with name 'WEB FLOW'
                  2009-11-03 19:39:29,731 DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapping [/customerWizard] to handler 'org.springframework.webflow.mvc.servlet.FlowController@1641923'
                  2009-11-03 19:39:29,731 TRACE [org.springframework.web.servlet.DispatcherServlet] - Testing handler adapter [org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter@1392fa5]
                  2009-11-03 19:39:29,731 TRACE [org.springframework.web.servlet.DispatcherServlet] - Testing handler adapter [org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter@1ed3030]
                  !!!!!!!!!!!!!!!!! countryId = 17560041000001 -- listing states
                  !!!!!!!!!!!!!!!!! countryId = 0 -- listing states
                  2009-11-03 19:39:31,184 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Null ModelAndView returned to DispatcherServlet with name 'WEB FLOW': assuming HandlerAdapter completed request handling
                  2009-11-03 19:39:31,184 TRACE [org.springframework.web.servlet.DispatcherServlet] - Cleared thread-bound request context: org.springframework.security.web.wrapper.SecurityContextHolderAwareRequestWrapper@1e39819
                  2009-11-03 19:39:31,184 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
                  2009-11-03 19:39:31,185 TRACE [org.springframework.web.context.support.XmlWebApplicationContext] - Publishing event in context [org.springframework.web.context.support.XmlWebApplicationContext@15d671a]: ServletRequestHandledEvent: url=[/PanoshopEngine/flow/customerWizard]; client=[0:0:0:0:0:0:0:1]; method=[POST]; servlet=[WEB FLOW]; session=[5A9A1C0CD6E4D32A1896F3734422FBB2]; user=[null]; time=[1455ms]; status=[OK]
                  2009-11-03 19:39:31,185 TRACE [org.springframework.web.context.support.XmlWebApplicationContext] - Publishing event in context [org.springframework.web.context.support.XmlWebApplicationContext@343bb6]: ServletRequestHandledEvent: url=[/PanoshopEngine/flow/customerWizard]; client=[0:0:0:0:0:0:0:1]; method=[POST]; servlet=[WEB FLOW]; session=[5A9A1C0CD6E4D32A1896F3734422FBB2]; user=[null]; time=[1455ms]; status=[OK]
                  2009-11-03 19:39:31,192 DEBUG [org.springframework.web.filter.RequestContextFilter] - Cleared thread-bound request context: org.springframework.security.web.wrapper.SecurityContextHolderAwareRequestWrapper@1e39819
                  


                  and here is PhaseTraker output:

                  03-Nov-2009 19:39:29 INFO org.exadel.jsf.PhaseTracker.beforePhase BEFORE RESTORE_VIEW 1
                  03-Nov-2009 19:39:29 INFO org.exadel.jsf.PhaseTracker.afterPhase AFTER RESTORE_VIEW 1
                  03-Nov-2009 19:39:29 INFO org.exadel.jsf.PhaseTracker.beforePhase BEFORE APPLY_REQUEST_VALUES 2
                  03-Nov-2009 19:39:29 INFO org.exadel.jsf.PhaseTracker.afterPhase AFTER APPLY_REQUEST_VALUES 2
                  03-Nov-2009 19:39:29 INFO org.exadel.jsf.PhaseTracker.beforePhase BEFORE PROCESS_VALIDATIONS 3
                  03-Nov-2009 19:39:29 INFO org.exadel.jsf.PhaseTracker.afterPhase AFTER PROCESS_VALIDATIONS 3
                  03-Nov-2009 19:39:29 INFO org.exadel.jsf.PhaseTracker.beforePhase BEFORE UPDATE_MODEL_VALUES 4
                  03-Nov-2009 19:39:29 INFO org.exadel.jsf.PhaseTracker.afterPhase AFTER UPDATE_MODEL_VALUES 4
                  03-Nov-2009 19:39:29 INFO org.exadel.jsf.PhaseTracker.beforePhase BEFORE INVOKE_APPLICATION 5
                  03-Nov-2009 19:39:29 INFO org.exadel.jsf.PhaseTracker.afterPhase AFTER INVOKE_APPLICATION 5
                  03-Nov-2009 19:39:31 INFO org.exadel.jsf.PhaseTracker.beforePhase BEFORE RENDER_RESPONSE 6
                  03-Nov-2009 19:39:31 INFO org.exadel.jsf.PhaseTracker.afterPhase AFTER RENDER_RESPONSE 6



                  • 6. Re: a4j:support fires event twice; and second time it passes
                    Sumeet Newbie

                    Hi,
                    Try to use the follwing way:

                    <h:selectOneMenu id="selOneRegion" value="#{flowScope.countryId}" styleClass="textBox" valueChangeListener="#{flowScope.countrySelected}" >
                     <f:selectItems value="#countrySelectItems}"/>
                     <a4j:support event="onchange" ajaxSingle="true"/>
                    </h:selectOneMenu>


                    try to use the ajaxSingle="true"

                    and try to use the valueChangelistener of selectOneMenu rather than the action of a4j:support

                    • 7. Re: a4j:support fires event twice; and second time it passes
                      Alexey Borschenko Newbie

                      Guys, thanx to your attention.

                      I found a bug in flow definition XML which caused that weird behavior.

                      Topic can be closed now I guess ;)