quality@glassfish.java.net

Re: Optional web.xml for JSF

From: Cay Horstmann <cay.horstmann_at_gmail.com>
Date: Sat, 11 Jun 2011 20:09:58 +0700

Thanks Ed! I think the rules changed. Originally, one of the rules was
"Any initialization parameters start with javax.faces". That would
have applied for me because I set the project stage. But the new rules
that you cite only apply to javax.faces.CONFIG_FILES. Not something
most people would fuss with...

That's too bad. Hopefully we can go back to the old rule.

I also noted that the rule "Any of the classes in the web application
uses a JSF 2.0 annotation" is gone. That is ok--my classes had CDI
annotations, and going forward, that's what one would expect.

Cheers,

Cay


2011/6/11 Ed Burns <edward.burns_at_oracle.com>:
> Can you please forward this to the email list.
>
> DP> Hi, I am pretty sure that GlassFish 3.0 did the faces/ or *.faces
> DP> mapping for JSF apps under one of three situations:
>
> DP>      Any of the classes in the web application uses a JSF 2.0 annotation
> DP>      Any initialization parameters start with javax.faces
> DP>      The WEB-INF/faces-config.xml file is present
>
> DP> At least that's what this blog said, so it must be right :-)
> DP> http://weblogs.java.net/blog/cayhorstmann/archive/2009/10/19/another-small-step-jsf
>
> DP> But I just happened to try this on GF 3.1. I had a web.xml file with
>
> DP>     <context-param>
> DP>        <param-name>javax.faces.PROJECT_STAGE</param-name>
> DP>        <param-value>Development</param-value>
> DP>     </context-param>
>
> DP> no JSF 2.0 annotations (because I used CDI) and no faces-config.xml
> DP> file. That was not enough to trigger the faces servlet. Adding an
> DP> empty faces-config.xml file did the trick, but it's pretty silly.
>
> DP> For the life of me, I can't figure out where I got those three
> DP> conditions--it's not in the JSF 2.0 spec, but I understand it will be
> DP> in the 2.1 spec.
>
> Yes, it's in the 2.1 spec.  The conditions that prevail for Mojarra
> 2.0.x are indeed in the 2.1 spec, in the javadoc for FacesServlet.
>
> http://javaserverfaces.java.net/nonav/docs/2.1/javadocs/javax/faces/webapp/FacesServlet.html
>
> ---------
>
> This servlet must automatically be mapped if it is not explicitly mapped
> in web.xml or web-fragment.xml and one or more of the following
> conditions are true.
>
>    * A faces-config.xml file is found in WEB-INF
>
>    * A faces-config.xml file is found in the META-INF directory of a
>      jar in the application's classpath.
>
>    * A filename ending in .faces-config.xml is found in the META-INF
>      directory of a jar in the application's classpath.
>
>    * The javax.faces.CONFIG_FILES context param is declared in web.xml
>      or web-fragment.xml.
>
>    * The Set of classes passed to the onStartup() method of the
>      ServletContainerInitializer implementation is not empty.
>
> If the runtime determines that the servlet must be automatically mapped,
> it must be mapped to the following <url-pattern> entries.
>
>    * /faces
>    * *.jsf
>    * *.faces
>
> ----
>
> DP> Can anyone shed any light on this? Was this just some implementation
> DP> detail that changed between 3.0 and 3.1?
>
> Are you certain it's not mapped in web.xml?  It may be a bug where, if
> you have the web.xml just for the purpose of setting the ProjectStage,
> we don't correctly check for the FacesServlet.
>
> Is that the case?
>
> Ed
>
> --
> | edward.burns_at_oracle.com | office: +1 407 458 0017
> | homepage:               | http://ridingthecrest.com/
> |  4 Business Days til JSF 2.2 Early Draft Review
> | 40 Business Days til JSF 2.2 Public Review
> | 128 Business Days til JSF 2.2 Proposed Final Draft
>