• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Including JSF pages in JSF pages

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic