10 Replies Latest reply on Apr 18, 2011 4:52 AM by mark77

    Problem with includes

    mark77

      Hi,

       

      after migrating my application from JSF1.2+RF3.3.3 to JSF2+RF4.0 I now have a problem with my dynamic includes.

       

      Before, I used the following code piece, to dynamically include page fragments:

       

       

      <c:forEach items="#{shopHandler.screen.leftColumn}" var="item">
                                                      <a4j:outputPanel width="100%">
      
                                                          <a4j:include viewId="#{item.src}"/>
                                                          <br/>
                                                      </a4j:outputPanel>
        </c:forEach>
      
      

       

      As a4j:include is now missing, I tried with ui:include, but this resulted in a fileNotFound Exception.

      I tried h:outputtext -ing the #{item} and although my bean returns a longer list for leftColumn, the loop just evaluates one time and #{item} is empty...

       

      for c: I use the following namespace: xmlns:c="http://java.sun.com/jstl/core"

       

      I meawhile even tried the jboss-el library, but - no luck.

       

      Any idea ?

        • 1. Problem with includes
          ilya_shaikovsky

          if you will look to generated source you will be probably see that tag just rendered as-is "<c:forEach...>...". Change xmlns to xmlns:c="http://java.sun.com/jsp/jstl/core" and it should start working.

          • 2. Problem with includes
            mark77

            Wow - that did the trick, thanks !

             

            I further had to include the jstl library in my pom:

             

            <dependency>
             
            <groupId>javax.servlet</groupId>
             
            <artifactId>jstl</artifactId>
             
            <version>1.1.2</version>
            </dependency>

             

            Strange thing is, that with JSF1.2 and RF3.3.3 everything worked without both changes...

            • 3. Problem with includes
              ilya_shaikovsky

              I guess you used JSP and not facelets previously..

              • 4. Problem with includes
                mark77

                No, it was always facelets, that's what puzzles me...

                 

                However, now my day is saved and I can proceed with the migration.

                Working with JSF2 is way more comfortable than with JSF1.2.

                 

                I am missing some components in RF4 really... the picklist and shuttle were fine; I of course can take them from PrimeFaces, but I'd prefer to have all components having the same look and feel. Were they just dropped to hold the release date or will they be lost forever ?

                • 5. Problem with includes
                  ilya_shaikovsky

                  as any popular and usefull component shuttles - just can't be klost for sure

                  see http://community.jboss.org/wiki/RichFacesMigrationGuide33x-4xMigration-Componentsmigration-RichOrderingComponents

                   

                  we just wanted to improve things there so postponed for more carefull design and review.

                  • 6. Problem with includes
                    mark77

                    That's good news.

                     

                    Thanks a lot for your great efforts and good work !

                    • 7. Re: Problem with includes
                      mark77

                      Now I am using:

                       

                       

                      {code:xml}<c:forEach items="#{shopHandler.screen.leftColumn}" var="item">

                                                                                  <f:subview>

                                                                                      <a4j:outputPanel width="100%">

                                                                                          <ui:include src="/#{shopHandler.theme}/#{item.src}">

                                                                                              <ui:param name="item" value="#{item}"/>

                                                                                          </ui:include>

                                                                                          <br/>

                                                                                      </a4j:outputPanel>

                                                                                  </f:subview>

                                                                              </c:forEach>{code}

                       

                       

                      With the now correct c-namespace, the loop is working, but... the parameter "item" is not available later, as i have the following in my included file:

                       

                       

                      {code:xml}<a4j:poll render="id_#{item.catalogBean.catalogid}" action="#{item.load}" rendered="#{not item.loaded}" status="status_#{item.catalogBean.catalogid}" />{code}

                       

                      The included parts are of different classes and only one of them provides this property loaded. However, it is detected correctly, but when the a4j:poll then tries to call the load method, i get a "resolved to null" in my log.

                      • 8. Re: Problem with includes
                        mark77

                        Oh.... seems to be an a4j:poll issue.

                         

                        I tried it with:

                         

                        <p:poll process="@this" interval="2" update="id_#{item.catalogBean.catalogid}" action="#{shopHandler.callLoad(item.id)}" rendered="#{not item.loaded}" />

                         

                        And this works as expected...

                        • 9. Re: Problem with includes
                          ilya_shaikovsky

                          I'm seeing different actions in a4j: and p: poll components.

                           

                          i get a "resolved to null" in my log.

                          Maybe while trying different component you made some additional corrections ?

                          • 10. Re: Problem with includes
                            mark77

                            The only thing I did was replacing a4j:poll  by p:poll.

                             

                            I assume that under the hood they behave quite different; obviously the foreach-item seems to not be evaluated upon the ajax postback if done via a4j:poll while p:poll seems to evaluate it at the render time and then encode it within the js-part, so there is no re-evaluation needed.