01: package com.icesoft.faces.facelets;
02:
03: import javax.faces.application.ViewHandler;
04:
05: import com.icesoft.util.SeamUtilities;
06: import com.sun.facelets.compiler.Compiler;
07: import com.sun.facelets.compiler.SAXCompiler;
08: import com.sun.facelets.impl.ResourceResolver;
09: 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 SEAM_EXPRESSION_FACTORY = "org.jboss.seam.ui.facelet.SeamExpressionFactory";
18:
19: // Log instance for this class
20: private static Log log = LogFactory
21: .getLog(D2DSeamFaceletViewHandler.class);
22:
23: public D2DSeamFaceletViewHandler(ViewHandler delegate) {
24: super (delegate);
25: }
26:
27: protected void faceletInitialize() {
28: /*
29: * If Seam1.2.1 or before then the SeamExpressionFactory exists in Seam so instantiate
30: * the faceletFactory that way; otherwise, just initialize the compiler without any
31: * options for Seam1.3.0.
32: * Need SeamUtilities class to determine if we require SeamExpressionFactory
33: *
34: */
35: try {
36: if (faceletFactory == null) {
37: com.sun.facelets.compiler.Compiler c = new SAXCompiler();
38: if (SeamUtilities.requiresSeamExpressionFactory()) {
39: c.setFeature(Compiler.EXPRESSION_FACTORY,
40: SEAM_EXPRESSION_FACTORY);
41: } //else just initialize the compiler without any extra seam settings
42: initializeCompiler(c);
43: faceletFactory = createFaceletFactory(c);
44: }
45: } catch (Throwable t) {
46: if (log.isDebugEnabled()) {
47: log.debug("Failed initializing facelet instance", t);
48: }
49: }
50: }
51:
52: /**
53: * @see D2DFaceletViewHandler#preChainResourceResolver(com.sun.facelets.impl.ResourceResolver)
54: */
55: protected ResourceResolver preChainResourceResolver(
56: ResourceResolver after) {
57: ResourceResolver seamDebugResourceResolver = SeamDebugResourceResolver
58: .build(after);
59: if (seamDebugResourceResolver != null)
60: return seamDebugResourceResolver;
61: else
62: return after;
63: }
64:
65: }
|