14 Replies Latest reply on Mar 14, 2007 3:13 PM by tizi

    <a4j:commandLink> action is not getting called

    tizi

      Hi,
      My <a4j:commandlink > action is not getting called. following is the code fragment:

      <a4j:outputPanel id="transInfo" ajaxRendered="true">
       <d:customDiv id="singleTrans" styleClass="component" rendered="#{processScope.renDerCustInfo == 'true'}" style="overflow: hidden;">
       <h:panelGrid columns="1" border="0" rendered="#{processScope.renDerOpportunity == 'true'}" columnClasses="colL" style="width:200px;margin-left: 47px;" rowClasses="rowH">
      
       <h:dataTable var="oppList" value="#{processScope.oppAllData}" columnClasses="colL" styleClass="dt_normal pr_red">
      
       <h:column>
       <a4j:commandLink action="#{backing_CustSearchBean.getOppNoData}" oncomplete="alert('after completion');">
       <h:outputText value="#{oppList.opp_no}" />
       <f:param name="opp_name" value="#{oppList.opp_no}" />
       </a4j:commandLink>
       </h:column>
       </h:dataTable>
       </h:panelGrid>
       </d:customDiv>
       </a4j:outputPanel>
      


      <a4j:commandLink> when clicked, my control doesn't go to getOppNoData action method of my managed bean. Please note that there are many other <h:panelgrids> inside <a4j:outputPanel />.
      I am doing similar coding on many other parts of the page with same managed bean, all the those actions
      are getting called.

      This probelm has stuck me up at a very imoportant phase. Please Help!!

        • 1. Re: <a4j:commandLink> action is not getting called

          Starts from <a4j:ajaxListener type="org.ajax4jsf.ajax.ForceRender" /> like it is shown here:
          http://livedemo.exadel.com/a4j-repeat-rerender/

          Also, if one of the parent that has rendered attribute and its value is false by default, the action should not be invoked

          • 2. Re: <a4j:commandLink> action is not getting called
            tizi

            Yes, infact it is the case that parent attribute has rendered attribute and its value is false by default. I need this logic, this block will be rendered later.

            are there any workarounds?

            • 3. Re: <a4j:commandLink> action is not getting called

              The logic is in the base UIComponent class. The decode phase is skipped if the component has rendered="false". The same for readonly and disabled attributes on the input components when they equals to false.

              This is a quote from the processDecodes method:

               ....
               // Skip processing if our rendered flag is false
               if (!isRendered()) { return;


              If you want to process the content, you need to have it true before the second phase. The session scope bean will work. However, it is pretty heavy solution.
              Ajax4jsf has a special component - a4j:keepAlive. It helps to restore the request scope bean, so it is shared between the Ajax requests

              If your case, it is <a4j:keepAlive beanName="processScope" />
              The bean saving with keepAlive should be serializable.

              BTW, your bean have #{processScope}. Does it mean it has lifecycle more then Request?

              • 4. Re: <a4j:commandLink> action is not getting called
                tizi

                do you mean rendered attribute I should set in session scope? If i use <a4j:keepalive> would it apply to my entire bean or can i refer to some specific property here?

                • 5. Re: <a4j:commandLink> action is not getting called
                  tizi

                  and yes processscope has bigger lifecycle than request. This scope has made available by ADF faces.

                  • 6. Re: <a4j:commandLink> action is not getting called
                    tizi

                     

                    "tizi" wrote:
                    and yes processscope has bigger lifecycle than request. This scope has been made available by ADF faces.


                    • 7. Re: <a4j:commandLink> action is not getting called

                      No. I did not mean you should set them to session scope, because it is not only one possible option.

                      The explanation to where the problem is:
                      http://tinyurl.com/2z2ckq

                      If you have a processScope, that is OK to solve the problem. However, we have one more question at this point. Does the ADF process scope work during the Ajax requests.

                      • 8. Re: <a4j:commandLink> action is not getting called
                        tizi

                        Hi,
                        Thanks for replying.
                        I put following statement at the top of the page.
                        <a4j:keepAlive beanName="backing_CustSearchBean" />

                        But now I am only able to see first page. If I click on any button, no data is being fetched.
                        Also my bean is in "request" scope only. ProcessScope I am using for transferring data b/w jsp and managedbean.

                        Can this problem be really resolved?

                        • 9. Re: <a4j:commandLink> action is not getting called

                          keepAlive keeps bean alive only during the requests on the same page.

                          There is a nature of request scope to have a limited lifecycle. If you want to have access to the data on several pages, the request scope is not for that. It is true for both Ajax and Non-Ajax mode

                          • 10. Re: <a4j:commandLink> action is not getting called
                            tizi

                            My application has only one page. Page is devided into 8 section which earlier use to be 8 different pages. Is there a specific place where I should place my <a4j:keepAlive>.

                            can this problem be resolved using any other tag like <htm:div>? Or are there any ways to manipulate rendered attribute?

                            • 11. Re: <a4j:commandLink> action is not getting called

                              Sorry, it looks like I misunderstood your post.

                              Did you try to use session scope? (just for the testing purpose)

                              • 12. Re: <a4j:commandLink> action is not getting called
                                tizi

                                yes I tried using session scope. But then it started messing with functionalities which were already in place.

                                Also I might not be related but I have following error on consol
                                Missing class: com.sun.facelets.FaceletViewHandler
                                Dependent class: org.ajax4jsf.framework.ViewHandlerWrapper

                                But I think it doesnt affect me anywhere. I really need to resolve this(command link action not getting called) issue soon. but it seems I dont have any way out.

                                If I use sessionscope for the bean I start getting "IllegalStateException"???

                                • 13. Re: <a4j:commandLink> action is not getting called

                                  The alternative way is using style attribute instead of rendered attribute. I mean, render the context anyway, but set display:none to hide it on the screen. It allows to avoid the problem with code in the UIComponent

                                  • 14. Re: <a4j:commandLink> action is not getting called
                                    tizi

                                    Thanks Sergey, for patiently replying to my posts.
                                    I resolved that issue by getting rid of <a4j:commandbutton> instead I used this inside my <h:datatable>:
                                    <h:outputLabel value="#{oppList.opp_no}" style="cursor:pointer" onclick="showOppSelected('#{oppList.opp_no}')"/>

                                    So I am getting the required functinality now.

                                    Thanks a lot for you help! Without your pointers I would not have been able to do this.