5 Replies Latest reply on Aug 27, 2009 4:20 AM by Ilya Shaikovsky

    <a4j:include> unable to include content conditionaly

    Yasir Qureshi Newbie

      Hi All,
      I am not able to include content based on some conditional expression using <a4j:include>, Here is my code:

      <a4j:include viewId="xyz.xhtml" ajaxRendered="true" rendered="#{aBean.condition}"/>
      


      I tried surrounding include in <a4j:ouputPanel> and giving its id to a reRender attribute of a command button on click of which I want above content to be included, it does not work either.

      Any ideas what is going wrong?

      Thanks,
      Yasir.

        • 1. Re: <a4j:include> unable to include content conditionaly
          Ilya Shaikovsky Master

          Try not to specify the rendered on include and specify it at outer conteiner instead. It's not a component but just tag and seems will not works as you need on such updates.

          • 2. Re: <a4j:include> unable to include content conditionaly
            Yasir Qureshi Newbie

            Thanks ilya_shaikovsky for your reply, I already tried surrounding it in <a4j:outputPanel> and put render attribute on it instead in include:

            <a4j:outputPanel ajaxRendered="true" rendered="#{myBean.conditiion}">
             <a4j:include viewId="abc.xhtml"/>
            </a4j:outputPanel
            


            Above does not work either. Any more clues?


            • 3. Re: <a4j:include> unable to include content conditionaly
              Ilya Shaikovsky Master

              Unfortunatelly there is the problem with conditional rendering occurs. you should use one more parent to update this outputPanel.

              • 4. Re: <a4j:include> unable to include content conditionaly
                Yasir Qureshi Newbie

                Thanks for the reply, I tried below combinations it still does not work I think <a4j:include> does not support conditional rendering.

                Does not work:

                <a4j:outputPanel ajaxRendered="true" rendered="#{myBean.conditiion}">
                 <a4j:outputPanel ajaxRendered="true">
                 <a4j:include viewId="abc.xhtml"/>
                </a4j:outputPanel>
                </a4j:outputPanel>
                


                Does not work:
                <a4j:outputPanel ajaxRendered="true">
                <a4j:outputPanel ajaxRendered="true" rendered="#{myBean.conditiion}">
                 <a4j:include viewId="abc.xhtml"/>
                </a4j:outputPanel>
                </a4j:outputPanel>
                


                Work w/o <a4j:include> <h:outputText> is rendered
                <a4j:outputPanel ajaxRendered="true">
                <a4j:outputPanel ajaxRendered="true" rendered="#{myBean.conditiion}">
                 <h:outputText value ="This is rendered"/>
                </a4j:outputPanel>
                </a4j:outputPanel>
                


                Below does not work with <a4j:include> <h:outputText> is not rendered too, i guess render attribute on <a4j:include> is causing problem
                <a4j:outputPanel ajaxRendered="true">
                <a4j:outputPanel ajaxRendered="true" rendered="#{myBean.conditiion}">
                 <h:outputText value ="This is rendered"/>
                </a4j:outputPanel>
                </a4j:outputPanel>
                


                Thanks,
                Yasir.

                • 5. Re: <a4j:include> unable to include content conditionaly
                  Ilya Shaikovsky Master

                   

                   <h:form>
                   <h:selectBooleanCheckbox value="#{userBean.shown}" >
                   <a4j:support ajaxSingle="true" event="onchange"/>
                   </h:selectBooleanCheckbox>
                   <a4j:outputPanel ajaxRendered="true">
                   <a4j:outputPanel rendered="#{userBean.shown}">
                   <a4j:include viewId="/richfaces/include/examples/wstep1.xhtml" />
                   </a4j:outputPanel>
                   </a4j:outputPanel>
                   </h:form>
                  


                  checked and works on my side.