KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > faces > facelets > D2DSeamFaceletViewHandler


1 package com.icesoft.faces.facelets;
2
3 import javax.faces.application.ViewHandler;
4
5 import com.icesoft.util.SeamUtilities;
6 import com.sun.facelets.compiler.Compiler;
7 import com.sun.facelets.compiler.SAXCompiler;
8 import com.sun.facelets.impl.ResourceResolver;
9 import org.apache.commons.logging.Log;
10 import org.apache.commons.logging.LogFactory;
11
12 /**
13  * @author ICEsoft Technologies, Inc.
14  */

15 public class D2DSeamFaceletViewHandler extends D2DFaceletViewHandler {
16
17     private static final String JavaDoc SEAM_EXPRESSION_FACTORY = "org.jboss.seam.ui.facelet.SeamExpressionFactory";
18     
19      // Log instance for this class
20
private static Log log = LogFactory.getLog(D2DSeamFaceletViewHandler.class);
21
22     public D2DSeamFaceletViewHandler(ViewHandler delegate) {
23         super(delegate);
24     }
25
26     protected void faceletInitialize() {
27     /*
28      * If Seam1.2.1 or before then the SeamExpressionFactory exists in Seam so instantiate
29      * the faceletFactory that way; otherwise, just initialize the compiler without any
30      * options for Seam1.3.0.
31      * Need SeamUtilities class to determine if we require SeamExpressionFactory
32      *
33      */

34         try {
35             if( faceletFactory == null ) {
36                 com.sun.facelets.compiler.Compiler c = new SAXCompiler();
37                 if ( SeamUtilities.requiresSeamExpressionFactory()){
38                     c.setFeature( Compiler.EXPRESSION_FACTORY, SEAM_EXPRESSION_FACTORY );
39                 } //else just initialize the compiler without any extra seam settings
40
initializeCompiler( c );
41                 faceletFactory = createFaceletFactory( c );
42             }
43         }
44         catch (Throwable JavaDoc t) {
45             if( log.isDebugEnabled() ) {
46                 log.debug("Failed initializing facelet instance", t);
47             }
48         }
49     }
50
51     /**
52      * @see D2DFaceletViewHandler#preChainResourceResolver(com.sun.facelets.impl.ResourceResolver)
53      */

54     protected ResourceResolver preChainResourceResolver(ResourceResolver after) {
55         ResourceResolver seamDebugResourceResolver =
56             SeamDebugResourceResolver.build(after);
57         if( seamDebugResourceResolver != null )
58             return seamDebugResourceResolver;
59         else
60             return after;
61     }
62     
63 }
64
Popular Tags