6 Replies Latest reply on Apr 5, 2007 10:19 AM by gzoller

    Anybody else experience a4j:support *not* calling action met

      Anybody had issues with a:support being flaky, specifically not calling the action/actionListener method when it should?

      I have the code below and session.hey is never called. FWIW I tried with and w/o the ajaxSingle attribute. Everything is rendered as expected w/proper values in the pull-down list, etc., and the "value" (workerName) is correctly set. I've also tried onblur as the event.

      Weird thing is I have another screen with virtually identical code except on a <h:inputText> field--and the action method is called. Hmm...

      Thanks,
      Greg

      <h:selectOneMenu id="worker"
       value="#{timecardHome.instance.workerName}">
       <f:selectItems value="#{app.activeWorkers}" />
       <a4j:support event="onchange"
       action="#{session.hey}"
       reRender="rate"
       ajaxSingle="true"/>
      </h:selectOneMenu>
      


        • 1. Re: Anybody else experience a4j:support *not* calling action
          christian.bauer

          What I was falling over a lot was that the reRender attribute really has to name a component that is _always_ rendered. So no or <s:div id="foo" rendered="sometimes">. Only <s:div id="foo"> works.

          • 2. Re: Anybody else experience a4j:support *not* calling action
            christian.bauer

            It might or might not have something to do with your issue but give it a shot. I still find it hard to debug what is going on.

            • 3. Re: Anybody else experience a4j:support *not* calling action

              Ok, this might be a bug...

              Everything on the page was always rendered, so that wasn't it. By process of elimination I identified the code causing the problem.

              This worked: (action method app.setTimecardWorker was called when item changed)

               <h:outputLabel styleClass="textLabel2" for="worker">Worker</h:outputLabel>
               <s:decorate>
               <h:selectOneMenu id="worker"
               value="#{timecardHome.instance.workerName}">
               <f:selectItems value="#{app.activeWorkers}" />
               <a4j:support event="onchange"
               action="#{app.setTimecardWorker(timecardHome.instance)}"
               reRender="rate"
               ajaxSingle="true"/>
               </h:selectOneMenu>
               </s:decorate>
               <h:outputLabel styleclass="textLabel2" for="rate">Rate $</h:outputLabel>
               <s:decorate>
               <h:inputText id="rate"
               required="true"
               size="3"
               value="#{timecardHome.instance.hourlyRate}"/>
               </s:decorate>
               <h:outputLabel styleClass="textLabel2" for="hours">Hours</h:outputLabel>
               <s:decorate>
               <h:inputText id="hours"
               required="true"
               size="3"
               value="#{timecardHome.instance.hours}"/>
               </s:decorate>
               <h:outputLabel styleclass="textLabel2" for="description">Description</h:outputLabel>
               <s:decorate>
               <h:inputText id="description"
               required="true"
               size="40"
               value="#{timecardHome.instance.description}"/>
               </s:decorate>
              


              This didn't (no action method was called when same item was changed)
               <h:outputLabel styleClass="textLabel2" for="worker">Worker</h:outputLabel>
               <s:decorate>
               <h:selectOneMenu id="worker"
               value="#{timecardHome.instance.workerName}">
               <f:selectItems value="#{app.activeWorkers}" />
               <a:support event="onchange"
               action="#{app.setTimecardWorker(timecardHome.instance)}"
               reRender="rate"
               ajaxSingle="true"/>
               </h:selectOneMenu>
               </s:decorate>
               <h:outputLabel styleclass="textLabel2" for="rate">Rate $</h:outputLabel>
               <s:decorate>
               <h:inputText id="rate"
               required="true"
               size="3"
               value="#{timecardHome.instance.hourlyRate}"/>
               </s:decorate>
               <h:outputLabel styleClass="textLabel2" for="month">Month</h:outputLabel>
               <s:decorate>
               <h:selectOneMenu id="month"
               converter="#{monthconverter}"
               value="#{timecardHome.instance.month}">
               <f:selectItems value="#{app.months}" />
               </h:selectOneMenu>
               </s:decorate>
               <h:outputLabel styleClass="textLabel2" for="hours">Hours</h:outputLabel>
               <s:decorate>
               <h:inputText id="hours"
               required="true"
               size="3"
               value="#{timecardHome.instance.hours}"/>
               </s:decorate>
               <h:outputLabel styleclass="textLabel2" for="description">Description</h:outputLabel>
               <s:decorate>
               <h:inputText id="description"
               required="true"
               size="40"
               value="#{timecardHome.instance.description}"/>
               </s:decorate>
              


              It seems adding the second select list did something to interfere with a4j:support calling the action method on the first select list. Bizarre!

              Any clues?
              Greg

              • 4. Re: Anybody else experience a4j:support *not* calling action
                christian.bauer

                Might want to ask in the ajax4jsf forum.

                • 5. Re: Anybody else experience a4j:support *not* calling action

                  I guess, if you add:

                  <a4j:outputPanel ajaxRendered="true">
                   <h:messages />
                  </a4j:outputPanel>

                  you can why the action is not invoked.

                  Instead of using ajaxSingle="true" surround s:decorate with <a4j:region>

                  • 6. Re: Anybody else experience a4j:support *not* calling action

                    Thanks Sergey!

                    The <a4j:region> did the trick. The <a4j:outputPanel> is quite handy! Haven't used that before. When I added that it revealed an exception trying to set a null value to the month pulldown. It really shouldn't have been trying to do anything with the month field, so using the region "focused" a4j into doing what I wanted.

                    Thanks again!
                    Greg