myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Garner Shawn" <shawndgar...@gmail.com>
Subject Re: sitemesh and jsf
Date Tue, 27 Feb 2007 20:46:51 GMT
I did post on the Sitemesh users list.  I haven't heard anything back yet.
This list is much more active than the sitemesh list.

Shawn

On 2/27/07, Simon Kitching <simon.kitching@rhe.co.nz> wrote:
>
> Well I guess you'll have to look at the source-code for the Sitemesh
> PageFilter then, or ask on the Sitemesh list. The problem is clearly
> that JSF-specific JSP tags are being executed but not within the scope
> of a FacesServlet. That's not a MyFaces problem, so unfortunately you're
> not likely to get much further help on this list.
>
> However if you do get this figured out it would be great if you could
> post the solution here (or add a page to the wiki) for anyone who
> encounters this in the future.
>
> Regards,
>
> Simon
>
> Garner Shawn wrote:
> > I tried this and it didn't work but am unsure why:
> >
> > "ExternalContext.dispatch to execute the jsp servlet for processing its
> > template so maybe it's just as simple as ensuring the decorators file
> > for Sitemesh uses ".jsf" urls rather than ".jsp" urls to its template
> > files, in order to trigger the FacesServlet rather than just the
> > jsp-handler servlet?"
> >
> > I got close by overriding the sitemesh filter and then doing a
> > chain.filter before calling the sitmesh filter.  It rendered the page
> > ok (not right) but it rendered the original page being decorated
> > twice.  Once at the beginning and then once later where it should have
> > been in the page.
> >
> >
> > Shawn
> > On 2/27/07, Simon Kitching <simon.kitching@rhe.co.nz> wrote:
> >> The project I am currently working on uses Sitemesh with MyFaces, ie the
> >> pages being *decorated* are JSF and it works. However the templates
> >> themselves will need to be JSP only (not JSF) I believe; that's
> >> certainly what we do.
> >>
> >> In order for a JSP page containing JSF tags to work correctly, the JSF
> >> FacesServlet must handle it. The FacesServlet sets up some JSF
> >> infrastructure  on entry, then executes the JSP page (using
> >> ExternalContext.dispatch). When JSF-specific tags execute the necessary
> >> JSF infrastructure is therefore present. However on completion of the
> >> servlet that infrastructure is destroyed by the FacesServlet.
> >>
> >> What the sitemesh *filter* does is initially pass the incoming request
> >> through without change so the primary "decorated" page is fetched, then
> >> it determines what decorator template to use and processes that
> >> *itself*. Sitemesh sets up the environment for its template to be
> >> correctly processed as jsp, but is not smart enough to set up the
> >> necessary environment for any JSF tags to execute successfully. And as
> >> described above the JSF-specific environment was set up on FacesServlet
> >> entry, but removed on FacesServlet exit so it is no longer available.
> >>
> >> We work around that somewhat by defining a custom "proxyInclude" tag
> >> which uses commons-httpclient to make requests. This tag can then be
> >> embedded into a Sitemesh template to insert JSF-generated data (in
> >> particular, a common header including a JsCookMenu menubar).
> >>
> >> Maybe the Sitemesh PageFilter could be improved to be JSF-aware but we
> >> haven't done that. Hmm..presumably the PageFilter does something like
> >> ExternalContext.dispatch to execute the jsp servlet for processing its
> >> template so maybe it's just as simple as ensuring the decorators file
> >> for Sitemesh uses ".jsf" urls rather than ".jsp" urls to its template
> >> files, in order to trigger the FacesServlet rather than just the
> >> jsp-handler servlet?
> >>
> >> Regards,
> >>
> >> Simon
> >>
> >>
> >> Ricardo Tercero Lozano wrote:
> >> > As far as I know you cannot use JSF in Sitemesh decorators.
> >> >
> >> > Ricardo.
> >> >
> >> >
> >> > On 2/26/07, *Garner Shawn* <shawndgarner@gmail.com
> >> > <mailto:shawndgarner@gmail.com>> wrote:
> >> >
> >> >     I'm trying to use sitmesh with JSF and am getting the following
> >> >     exception:
> >> >     This is my template decorator page and has a f:view page.
> >> >     Is there something I have to do with this to initialize the
> >> >     FacesContext for the decorators/templates?
> >> >
> >> >
> >> >     javax.faces.FacesException: Faces context not found.
> >> getResponseWriter
> >> >     will fail. Check if the FacesServlet has been initialized at all in
> >> >     your web.xml configuration fileand if you are accessing your
> >> jsf-pages
> >> >     through the correct mapping. E.g.: if your FacesServlet is
> >> mapped to
> >> >     *.jsf (with the <servlet-mapping>-element), you need to access
your
> >> >     pages as 'sample.jsf'. If you tried to access 'sample.jsp',
> >> you'd get
> >> >     this error-message.
> >> >            javax.faces.webapp.UIComponentTag.setupResponseWriter
> >> >     (UIComponentTag.java:926)
> >> >
> >> >
> >> javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:313)
> >> >
> >> >     org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:73)
> >> >
> >> >     org.apache.jsp.decorators.andreasTemplate_jsp._jspx_meth_f_view_0
> >> >     (andreasTemplate_jsp.java:146)
> >> >
> >> >
> >> org.apache.jsp.decorators.andreasTemplate_jsp._jspService(andreasTemplate_jsp.java:122)
> >>
> >> >
> >> >     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:332)
> >>
> >> >
> >> >
> >> 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.age.j.soft.sitemesh.TemplateFilterImpl.applyDecorator(TemplateFilterImpl.java:49)
> >>
> >> >            com.opensymphony.module.sitemesh.filter.PageFilter.doFilter
> >> >     (PageFilter.java:62)
> >> >
> >> >
> >> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
> >>
> >> >
> >> >
> >>
> >>
>
>

Mime
View raw message