4 Replies Latest reply on Mar 13, 2007 1:44 AM by wklaus

    reRender Problem

    wklaus

      Hi,
      I have the following page layout:


      <h:form>
      <t:datatable>
      <h:column>
      <t:input id="konf">
      <a4j:support event="onfocus" reRender="detail"/>
      </h:column>
      few mor columns
      </t:datable>
      <a4j:region>
      <h:panelGrid id="detail">
      Some elements
      <a4j:commandButton id="ktext" action="dosomething" reRender="ktspezid,kannTextGrid">
      </h:panelGrid>
      </a4j:region>
      </h:form>

      <h:form>
      <h:inputHidden value="ktspezid"/>
      <h:panelGrid id="kannTextGrid">
      <h:inputText....>
      </h:panelGrid>
      <h:form>

      The "detail"-Grid is reRendered as expected. My problem now is that if I click on button "ktext" I want the ids ktspezid and kannTextGrid of the second form reRendered. But in the response there are
      no "Ajax-Update-Ids". I also tried to put the complete second form
      in a <a4j:region> but this doesn't change anything.
      How can I reRender ids in the second form? Is this generally possible?

      Everything works fine if I use a4j:page right after <f:view> but the page
      is realy big and it takes a long time till the request is completed.
      I'm using MyFaces 1.1.5 and ajax4jsf 1.0.7.

      Thank you

      Regards

      Wolfgang

        • 1. Re: reRender Problem

          if you still use 1.0.7, you need to use <a4j:region renderRegionOnly="false"> (it is set to false by default in 1.1.0). Also, reRender uses findComponent() approach to find the component with particular id. So, if the re-rendered components are outside of the same form, the path should be different.

          <........ reRender=":myform:ktspezid, :myform:kannTextGrid" />
           ...
           <h:form id="myform">
           <h:inputHidden value="ktspezid"/>
           <h:panelGrid id="kannTextGrid">
           <h:inputText....>
           </h:panelGrid>
          <h:form>


          • 2. Re: reRender Problem

            Hi Sergey,

            I'm using 1.1.0 and can't get a nested DataTable to rerender. (I'm going for an expandable list: list items expands showing details.) Its all in the same form.

            Like this:

             <h:form id="deptYear">
             <h:dataTable id="departmentListResults" width="100%" cellspacing="1"
             value="#{departmentList.resultList}" var="dept">
             <h:column>
             <h:panelGrid columns="3" width="100%" cellspacing="0" cellpadding="0"
             columnClasses="deptClass1,deptClass2,deptClass3">
            
             <a4j:commandButton
             id="expandList"
             title="Click here to open or close"
             reRender="expandList,gwz,projListResults"
             image="#{main.imageMap[dept]}"
             action="#{main.pressExpandButton(dept)}"
             >
             <a4j:ajaxListener type="org.ajax4jsf.ajax.ForceRender" />
             </a4j:commandButton>
            
             <h:outputText value="#{dept.name}" styleClass="highlight"/>
             <h:outputText id="gwz" value="#{main.imageMap[dept]}"/>
             </h:panelGrid>
             <h:dataTable id="projListResults" width="100%" cellspacing="1"
             value="#{dept.projects}" var="proj"
             rendered="#{main.imageMap[dept]=='img/arrow_open.gif'}">
             <h:column>
             <h3>Hey! #{main.imageMap[dept]}</h3>
             </h:column>
             </h:dataTable>
             </h:column>
             </h:dataTable>
             </h:form>
            


            In this code the rerendered items on the detail line (the button image and gwz) both rerender just fine. My nested detail DataTable (projListResults) doesn't automatically rerender. Only if I it refresh on the browser to reload the whole page does it show the correct result.

            I've tried using :deptYear:projListResults but that didn't work.

            Any ideas? Thanks!
            Greg

            • 3. Re: reRender Problem

              Ok, I have made some progress that allows this functionality to work, but mysteries remain.

              Here's the working code:

               <h:form id="deptYear">
               <h:dataTable id="departmentListResults" width="100%" cellspacing="1"
               value="#{departmentList.resultList}" var="dept">
               <h:column>
               <h:panelGrid columns="3" width="100%" cellspacing="0" cellpadding="0"
               columnClasses="deptClass1,deptClass2,deptClass3">
              
               <a4j:commandButton
               id="expandList"
               title="Click here to open or close"
               reRender="expandList,gwz,projListResults"
               image="#{main.imageMap[dept]}"
               action="#{main.pressExpandButton(dept)}"
               >
               <a4j:ajaxListener type="org.ajax4jsf.ajax.ForceRender" />
               </a4j:commandButton>
              
               <h:outputText value="#{dept.name}" styleClass="highlight"/>
               <h:outputText id="gwz" value="#{main.imageMap[dept]}"/>
               </h:panelGrid>
               <a4j:region>
               <h:dataTable id="projListResults" width="100%" cellspacing="1"
               value="#{dept.projects}" var="proj">
               <h:column>
               <h:outputText id="blah"
               rendered="#{main.imageMap[dept]=='img/arrow_open.gif'}"
               value="Hey! #{main.imageMap[dept]}"/>
               </h:column>
               </h:dataTable>
               </a4j:region>
               </h:column>
               </h:dataTable>
               </h:form>
              


              I added an <a4j:region> around the nested DataTable. This allowed elements in this table to be rerendered from the a4j:commandButton in the parent table. That's good, but I had problems with getting rendered (not rerender) to work. I want to show or not show the detail panel based on the status of the expand button (a4j:commandButton).

              If I added a render attribute w/boolean logic to either a4j:region, or the nested h:dataTable it was completely ignored. The detail table was always rendered. However if I add render attributes to elements within the nested h:dataTable the correct behavior happens: they render or not based on the boolean logic.

              So why do I need to add boolean logic to every element in the nested table rather than just the table itself? That would be a whole lot easier. Is this a bug or reasonable and expected behavior?

              Thanks,
              Greg

              • 4. Re: reRender Problem
                wklaus

                Hi Sergey,

                thanks for your hints. No the page works very well.

                Regards

                Wolfgang