3 Replies Latest reply on Apr 28, 2011 2:32 AM by yesudas

    Not rendering on actionListener if I generate a component dynamically

    yesudas

      I have two panels, left panel and right panel.

       

      There are some links available in the left panel which will work like menu.

      On click of these links the content in the right panel will be rendered dynamically.

       

      Following is the code for command link:

       

      <a4j:commandLink value="Region" reRender="dynamicDataTable"

          actionListener="#{dynamicManagedBean.loadMenuContent}" id="regioncl">

           <f:setPropertyActionListener target="#{dynamicManagedBean.currentXmlFileName}" value="region.xml" />

      </a4j:commandLink>

       

       

       

      Now, the right content is generated dynamically through my backing bean based on the cofigurations available in the "region.xml" file as per above example.

      I have used one wrapping panel Grid and i have added some components like input text boxes and buttons as children to this wrapping panel grid.

       

      Im binding this wrapping panel grid in the xhtml as shown below:

       

      <a4j:outputPanel id="dynamicDataTable">

          <h:form id="commonForm1">

              <h:panelGrid binding="#{dynamicManagedBean.dynaGrid}"

                  dir="#{msg.component_dir}" width="100%">

              </h:panelGrid>

          </h:form>

      </a4j:outputPanel>

       

      The Problem is:

      The problem is, when i use actionListener for the commandLink, it is not re-rendering the right content.

      But if i use action for the commandLink, it is re-rendering, but, it is refreshing the entire page.

      I do not want the entire page to be refreshed.

       

      Can anyone help me to solve this problem?

        • 1. Not rendering on actionListener if I generate a component dynamically
          ilya_shaikovsky

          whole page refreshed seems because you returning some outcome(pointed to the same page?).

           

          and about first problem - add layout = block to the outputPanel. currently it rendered as span and you have table inside(rendered by panelGrid) - it's incorrect html

          • 2. Re: Not rendering on actionListener if I generate a component dynamically
            yesudas

            ilya

            i have added layout=block as you suggested.

            Still the problem is existing.

             

            <a4j:outputPanel id="dynamicDataTable" layout="block">

                <h:form id="commonForm1">

                    <h:outputText id="out" value="#{dynamicManagedBean.currentXmlFileName}"/>

                    <h:panelGrid binding="#{dynamicManagedBean.dynaGrid}"

                        dir="#{msg.component_dir}" width="100%">

                    </h:panelGrid>

                </h:form>

            </a4j:outputPanel>

             

            I added a outputText as highlighted in green.

            It is rendering fine.

            When the user clicks on region, it will display region.xml.

            When the user clicks on country, it will display country.xml.

            But, panelGrid is not rendering.

             

            below is the commandlinks for your reference:

                           <a4j:commandLink value="Region" reRender="dynamicDataTable"

                                actionListener="#{dynamicManagedBean.loadMenuContent}" id="regioncl">

                                 <f:setPropertyActionListener target="#{dynamicManagedBean.currentXmlFileName}" value="region.xml" />

                            </a4j:commandLink>

                            <br /><br />

                            <a4j:commandLink value="Country" reRender="dynamicDataTable"

                                actionListener="#{dynamicManagedBean.loadMenuContent}" id="countrycl">

                                 <f:setPropertyActionListener target="#{dynamicManagedBean.currentXmlFileName}" value="country.xml" />

                            </a4j:commandLink>

            • 3. Re: Not rendering on actionListener if I generate a component dynamically
              yesudas

              Hi ilya,

               

              I have created a reproducable example with an xhtml page and backing bean and attached here.

               

              It will help you to figure out the problem easily.

               

              Please help me to solve this issue.

               

              Let me know if you require any config files like web.xml, faces-config.xml.