webtier@glassfish.java.net

Re: [webtier] Glassfish not compliant with jsf 2.0 spec?

From: Jason Lee <jasondlee_at_sun.com>
Date: Sat, 27 Feb 2010 21:21:10 -0600

  That should be in <factory>:

    <factory>
    <application-factory>com.bespokecode.jsf.extensions.CustomApplicationFactory</application-factory>
    </factory>

See section 11.4.5 of the spec as well as the XSD in Appendix A.

Hope that helps.


On 2/27/10 2:42 PM, webtier_at_javadesktop.org wrote:
> First of All, sorry but I couldn't find anyway of formatting the code here.
>
> Now my problem:
>
> According to the section 11.2.6.1 of the JSF 2.0 Spec,
>
> I can override the default ApplicationFactory by specifying this in my faces-config.xml
>
> This is what I have done but my code is NEVER called.
>
> Below is my faces-config.xml
>
> <faces-config version="2.0"
> xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
> <application>
> <application-factory>
> com.bespokecode.jsf.extensions.CustomApplicationFactory
> </application-factory>
>
> <action-listener>
> com.bespokecode.jsf.extensions.CustomActionListener
> </action-listener>
> </application>
>
> </faces-config>
>
> And this is my CustomApplicationFactory
>
> public class CustomApplicationFactory extends ApplicationFactoryImpl {
>
> // Log instance for this class
> private static final Logger logger = FacesLogger.APPLICATION.getLogger();
>
> private volatile Application application;
>
> public CustomApplicationFactory() {
> super();
> System.out.println("Custom Application constructor called");
> }
>
> @Override
> public Application getApplication() {
> System.out.println("get Application called");
>
> if (application == null) {
> application = new CustomApplication();
> if (logger.isLoggable(Level.FINE)) {
> logger.fine(MessageFormat.format("Created Application instance ''{0}''",
> application));
> }
> }
> return application;
> }
>
> }
>
>
> All I have done in my CustomApplicationFactory is to extend the ApplicationFactoryImpl so I can provide my own Application class. None of the messages in this class gets written anywhere and when I try to retreive the Application class like this
>
> CustomApplication application = (CustomApplication) context.getApplication();
>
> I get a class ClassCastException which says :
>
> java.lang.ClassCastException: com.sun.faces.application.ApplicationImpl cannot be cast to com.bespokecode.jsf.extensions.CustomApplication
>
> AM I doing something wrong or its the mojara code that is not doing it properly?
>
> Just FYI, this is the CustomApplication class, nothing fancy
>
> public class CustomApplication extends ApplicationImpl{
>
> private SecurityManager securityManager;
>
> public CustomApplication() {
> super();
> }
>
> public SecurityManager getSecurityManager() {
> return securityManager;
> }
>
> public void setSecurityManager(SecurityManager securityManager) {
> this.securityManager = securityManager;
> }
> }
> [Message sent by forum member 'gcameo' (osbert252003_at_yahoo.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=389138
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: webtier-help_at_glassfish.dev.java.net
>
>


-- 
Jason Lee
Senior Member of Technical Staff
GlassFish Administration Console
Oracle Corporation
Phone x31197/+1 405-343-1964
Email jasondlee_at_sun.com
Blog http://blogs.steeplesoft.com