01: package com.icesoft.faces.facelets;
02:
03: import com.sun.facelets.tag.jsf.ComponentHandler;
04: import com.sun.facelets.tag.jsf.ComponentConfig;
05: import com.sun.facelets.tag.TagAttribute;
06: import com.sun.facelets.FaceletContext;
07: import com.icesoft.faces.component.UIXhtmlComponent;
08:
09: import javax.faces.component.UIComponent;
10:
11: /**
12: * @author Mark Collette
13: * @since 1.6
14: */
15: public class UIXhtmlComponentHandler extends ComponentHandler {
16: public UIXhtmlComponentHandler(ComponentConfig componentConfig) {
17: super (componentConfig);
18: }
19:
20: /**
21: * @see ComponentHandler#createComponent(FaceletContext)
22: */
23: protected UIComponent createComponent(FaceletContext ctx) {
24: //System.out.println("UIXhtmlComponentHandler.createComponent() tag: " + tag + " tagId: " + tagId);
25: UIXhtmlComponent current = new UIXhtmlComponent();
26: current.setCreatedByFacelets();
27: current.setTag(tag.getQName());
28: TagAttribute[] attribs = tag.getAttributes().getAll();
29: for (int i = 0; i < attribs.length; i++) {
30: String qName = attribs[i].getQName();
31: if (attribs[i].isLiteral()) {
32: String value = attribs[i].getValue();
33: current.addStandardAttribute(qName, value);
34: } else {
35: // We don't always include the EL jars, so our
36: // code has to use reflection to refer to
37: // javax.el.ValueExpression
38: Object value = attribs[i].getValueExpression(ctx,
39: Object.class);
40: current.addELValueExpression(qName, value);
41: }
42: }
43: return current;
44: }
45:
46: protected void setAttributes(FaceletContext ctx, Object instance) {
47: // Do nothing here, since UIXhtmlComponent sets up its properties
48: // differently than other UIComponents
49: }
50:
51: /*
52: protected UIComponent applyToCurrent(FaceletContext ctx, UIComponent wrapped)
53: throws IOException, FacesException {
54: UIXhtmlComponent current = new UIXhtmlComponent();
55: current.setCreatedByFacelets();
56: current.setTag(tag.getQName());
57: String id = null;
58: TagAttribute[] attribs = tag.getAttributes().getAll();
59: for(int i = 0; i < attribs.length; i++) {
60: String qName = attribs[i].getQName();
61: if( attribs[i].isLiteral() ) {
62: String value = attribs[i].getValue();
63: if( qName.equals("id") )
64: id = value;
65: current.addStandardAttribute(qName, value);
66: }
67: else {
68: // We don't always include the EL jars, so our
69: // code has to use reflection to refer to
70: // javax.el.ValueExpression
71: Object value =
72: attribs[i].getValueExpression(ctx, Object.class);
73: current.addELValueExpression(qName, value);
74: }
75: }
76: // com.sun.facelets.tag.jsf.ComponentHandler.apply(-)
77: // assigns ids in a similar fashion
78: if( id != null ) {
79: current.setId( ctx.generateUniqueId(id) );
80: }
81: else {
82: UIViewRoot root =
83: ComponentSupport.getViewRoot( ctx, wrapped );
84: if( root != null ) {
85: current.setId( root.createUniqueId() );
86: }
87: }
88: return current;
89: }
90: */
91: }
|