File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Including JSF pages in JSF pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Including JSF pages in JSF pages" Watch "Including JSF pages in JSF pages" New topic
Author

Including JSF pages in JSF pages

Abhishek Dwaraki
Ranch Hand

Joined: Feb 13, 2006
Posts: 44
I need to make my page inclusion dynamic for the project module that I'm working on... So everything is broken down to a component level. The problem is that my main page, say template.jsp, mapped into the Faces Servlet as *.faces is just a simple page consisting of a number of <jsp:include page= > tags which just bring in a number of *.inc files with jsp content. The rendering works fine till I do a nesting... That is I use a <jsp:include page= > tag in one of the .inc files themselves which calls another JSF. I get an Assertion Failed error. The trace is below. There is no circular reference in the nesting. Could someone plz help me out in this regard....? Thanks in advance.

THIS IS THE EXCEPTION TRACE THAT I GET...
exception

javax.servlet.ServletException: javax.servlet.jsp.JspException: Assertion Failed
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:844)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.template_jsp._jspService(org.apache.jsp.template_jsp:455)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)


root cause

javax.faces.FacesException: Assertion Failed
com.sun.faces.util.Util.doAssert(Util.java:1316)
com.sun.faces.taglib.jsf_core.ViewTag.getComponentType(ViewTag.java:237)
javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1022)
javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1045)
javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:742)
javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:423)
com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:105)
org.apache.jsp.template_jsp._jspx_meth_f_view_1(org.apache.jsp.template_jsp:470)
org.apache.jsp.template_jsp._jspService(org.apache.jsp.template_jsp:410)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)


Regards,
Abhishek Dwaraki
Dept of Electrical and Comp Engg
University of Massachusetts, Amherst
Peter Goldstein
Greenhorn

Joined: Feb 26, 2006
Posts: 15
There are rules when including JSF pages that need to be followed.

i) The "top level" JSF page must have an <f:view> tag surrounding all JSF tags being used. Since you seem to be mixing and matching simple JSPs and JSF pages I'm not clear if that will always be the case in what you describe

ii) The content of the included JSF (faces) page fragments need to be surrounded with <f:subview> tags. These <f:subview> tags can either be in the included page or surround the include statement in the including page. Either is fine.

iii) All non JSF tags and content in the included JSF (faces) page fragments need to be surrounded by <f:verbatim> tags.

If you're using JSF with a JSP renderer, make sure you're following all of these rules.

If you're building a system with lots of includes and you're using JSF, I'd probably suggest that you consider Facelets. It eliminates requirement (iii) and has expanded support for templating and dynamic inclusion. It does however introduce a few other requirements, most notably that your pages be strict XML. I have been pretty happy with Facelets' features and performance, but your mileage may vary.

--Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Including JSF pages in JSF pages