2 Replies Latest reply on Nov 25, 2008 10:22 AM by fgc_fernando

    Problems using a4j:include dynamically

      Hello folks,

      I'm trying to use the a4j:include component dynamically using Java.
      I've created a simple page and bean, so that you can give me some light on this problem...

      My test.jsp page

      <%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
      <%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
      <%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
      <%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
      
      <f:view>
      <html>
       <body>
       <h:form>
       <a4j:outputPanel layout="block">
       JSP include:
       <a4j:include viewId="included.jsp"/>
       </a4j:outputPanel>
      
       <a4j:outputPanel layout="block" binding="#{PanelBean.panel}">
       </a4j:outputPanel>
       </h:form>
       </body>
      </html>
      </f:view>
      


      In this page, I've created 2 panels:
      - one with a4j:include tag (which works fine)
      - the other with a component binding. The include is added to the panel dynamically

      This is the included page (included.jsp):
      Hello!
      


      And this is PanelBean (app.PanelBean):
      package app;
      
      import javax.annotation.PostConstruct;
      import javax.faces.component.html.HtmlOutputText;
      
      import org.ajax4jsf.component.html.HtmlAjaxOutputPanel;
      import org.ajax4jsf.component.html.Include;
      
      public class PanelBean {
       private HtmlAjaxOutputPanel panel;
      
       @PostConstruct
       public void init(){
       panel = new HtmlAjaxOutputPanel();
      
       HtmlOutputText txt = new HtmlOutputText();
       txt.setValue("Java code include: ");
      
       Include include = new Include();
       include.setViewId("included.jsp");
      
       panel.getChildren().add(txt);
       panel.getChildren().add(include);
       }
      
       public HtmlAjaxOutputPanel getPanel() {
       return panel;
       }
      
       public void setPanel(HtmlAjaxOutputPanel panel) {
       this.panel = panel;
       }
      }
      

      As can be seen in the init() method, I've created a simple output text and an include component. The output text is rendered. The include is not.

      When the page is accessed, it prints:
      JSP include: Hello!
      Java code include:
      


      When I would like it to print:
      JSP include: Hello!
      Java code include: Hello!
      


      I'm using:
      Tomcat 6.0
      JSF SUN RI 1.2_09-b02-FCS
      Richfaces 3.2.2.GA

      Does anybody have some ideas how to resolve this problem?

      Thanks in advance!