2 Replies Latest reply on May 25, 2010 9:37 AM by Giorgio Cortesi

    c:foreach or rich:columns?

    Giorgio Cortesi Newbie

      Hi everybody....this is my situation....i have a simple bean MdStore which have the master data details on it....plus it has an arraylist of other bean (from a onetomany relation).....
      so i can call



      MdStore s : new MdStore(bla bla bla)


      s.getName();
      s.getAddress();
      s.getagrPallet().get(0)   (this is an arraylist.....)




      the point is....
      why this don't work? it only shows first row.....i tried every kind of method, columns, c:foreach, a:repeat, but it doesn't want to work....what i want to reach is a simple table with all the detail of a store in a single row....


      like...


      storecode1   storename1 store.agrpallet(0).type  store.agrPallet(1).type ecc..
      storecode2   storename2
      store.agrpallet(0).type  store.agrPallet(1).type ecc..
      storecode3   storename3 store.agrpallet(0).type  store.agrPallet(1).type ecc..

      this is my code:


       
      
      <rich:panel id="paneltable">      
                  <rich:dataTable value="#{storesList}" var="stor" id="table">
                                      <rich:column >
                                              <f:facet name="header">
                                                      <h:outputText value="#{messages['store.name']}" />
                                              </f:facet>
                                              <h:outputText value="#{stor.name}"/>
                                      </rich:column>
                                      
                                      <rich:columns value="#{stor.agrPalAm}" var="pal">
                                              <f:facet name="header">
                                                      <h:outputText value="#{pal.id.typePallet}" />
                                              </f:facet>
                                              <h:outputText value="#{pal.amountPallet}" />
                                      </rich:columns>
                                      
                  </rich:dataTable>
                      </rich:panel>








        • 1. Re: c:foreach or rich:columns?
          Ilya Shaikovsky Master

          The rich:columns tag(the same for c:forEach) is initialized during components tree building process. This process precedes page rendering at Render Response JSF phase. So you can't use variable from dataTable VAR as value for the tags.


          As for repeat component - them should works fine in this case. Need more info on that.

          • 2. Re: c:foreach or rich:columns?
            Giorgio Cortesi Newbie
            Thankyou Ilya for your help...the problem (as i could understand) was that i was trying to specify to the rich columns tag a variable which haven't value during (as u say) the component tree building....so that the dynamic behavior of the tag was a bit "too dynamic"....the only "problem" was that it didn't show me an error, or an alert, nothing it was just rendering the empty table...maybe this should be fixed, or changed, cuz it was very hard to me to understand....maybe impossible if it wasn't for ur help....

            Or maybe this can be better specified in the docs....something like: IN THE RICH:COLUMNS "VALUE" ATTRIBUTE, YOU MUST SPECIFY A VARIABLE THAT CAN BE _RESOLVED_ DURING TREE BUILDING PROCESS...otherwise, the rich columns cannot manage the "dinamicity" of the table and it doesn't show anything (empty table or the other "normal" column tag)...

            this is how i fixed my error...i specified the number of columns by a query not based on the store, but based on another thing which could be resolved earlier, like a "constant" for the rendering phase of my page...

            this is the code...(agreementEditor is a session bean who makes my lists and queries....palletList() is a query with no parameters which returns a FIXED lists of strings....

            `
            <rich:panel id="paneltable">     
                        <rich:dataTable value="#{storesList}" var="stor" id="table">
                                            <rich:column >
                                                    <f:facet name="header">
                                                            <h:outputText value="#{messages['store.name']}" />
                                                    </f:facet>
                                                    <h:outputText value="#{stor.name}"/>
                                            </rich:column>
                                           
                                           <rich:columns value="#{agreementEditor.palletList()}" var="pal" ind="ind">
                                                    <f:facet name="header">
                                                            <h:outputText value="#{pal}" />
                                                    </f:facet>
                                                    <h:outputText value="#{stor.pallet.amountValue}" />
                                            </rich:columns>
                                           
                        </rich:dataTable>
                            </rich:panel>`




            .hope i explain myself the right way, and that this could help anyone...maybe i made some 'theoric error' =D