webtier@glassfish.java.net

Re: [webtier] Re: faceletContext-> getFacesContext() -> getResponseWriter() is null --- WHY?

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Mon, 23 Nov 2009 09:19:11 -0800

The response writer typically isn't created until it's needed (i.e., the
render response phase).
That said, FacesContext.getResponseWriter() isn't responsible for
creating the writer,
so if you want to do some writing during the tag apply() call, you'll
need to get the ResponseWriter
from the desired RenderKit and pass it to the FacesContext.


On 11/19/09 12:28 PM, webtier_at_javadesktop.org wrote:
> Here is more detail:
>
> My TagHandler is..
>
>
> import com.sun.facelets.tag.TagHandler;
> import com.sun.facelets.tag.TagConfig;
> import com.sun.facelets.tag.TagAttribute;
> import com.sun.facelets.FaceletContext;
> import com.sun.facelets.FaceletException;
>
> public class PortletSetDisplayTag extends TagHandler{
>
> private FacesContext context;
>
> public PortletSetDisplayTag(TagConfig tagConfig) {
> super(tagConfig);
>
> /* Initialize attributes */
> }
>
>
>
>
> public void apply(FaceletContext faceletContext, UIComponent component) throws IOException, FacesException, FaceletException, ELException {
>
> faceletContext.getFacesContext().getResponseWriter().write("Hello"); //this is just bottom line what I trying to achieve
> // but faceletContext.getFacesContext().getResponseWriter() is NULL
> }
>
>
>
>
>
> Taglib file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE facelet-taglib PUBLIC
> "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
> "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
> <facelet-taglib>
> <namespace>http://tag.custom/wlec-tag</namespace>
> <tag>
> <tag-name>portletSetRenderer</tag-name>
> <handler-class>com.legaledcenter.jsf.tag.PortletSetDisplayTag</handler-class>
> </tag>
> </facelet-taglib>
>
>
>
>
> When I use javax* classes, the server gives error:
> SEVERE: Error Loading Library: /WEB-INF/taglib/portletSetDisplayTag.taglib.xml
> java.io.IOException: Error parsing [jndi:/localhost/WEB-INF/taglib/portletSetDisplayTag.taglib.xml]:
> at com.sun.facelets.compiler.TagLibraryConfig.create(TagLibraryConfig.java:410)
>
> Caused by: org.xml.sax.SAXException: Error Handling jndi:/localhost/WEB-INF/taglib/portletSetDisplayTag.taglib.xml_at_9,90<handler-class>
> at com.sun.facelets.compiler.TagLibraryConfig$LibraryHandler.endElement(TagLibraryConfig.java:271)
>
> One more Observation:
> I see this while starting tomcat 6:
>
> WARNING: JSF1069: Disabling the JSF 2.0 Facelets ViewHandler as an older FaceletViewHandler, com.sun.facelets.FaceletViewHandler, has been explicitly configured. If this is not desired behavior, remove the older FaceletViewHandler and library from your application.
>
> Please help!
> Thanks
> [Message sent by forum member 'tahirraza' ]
>
> http://forums.java.net/jive/thread.jspa?messageID=372586
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: webtier-help_at_glassfish.dev.java.net
>
>