KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.icesoft.faces.facelets;
2
3 import com.sun.facelets.tag.jsf.ComponentHandler;
4 import com.sun.facelets.tag.jsf.ComponentConfig;
5 import com.sun.facelets.tag.TagAttribute;
6 import com.sun.facelets.FaceletContext;
7 import com.icesoft.faces.component.UIXhtmlComponent;
8
9 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 JavaDoc qName = attribs[i].getQName();
31             if( attribs[i].isLiteral() ) {
32                 String JavaDoc value = attribs[i].getValue();
33                 current.addStandardAttribute(qName, value);
34             }
35             else {
36                 // We don't always include the EL jars, so our
37
// code has to use reflection to refer to
38
// javax.el.ValueExpression
39
Object JavaDoc value =
40                         attribs[i].getValueExpression(ctx, Object JavaDoc.class);
41                 current.addELValueExpression(qName, value);
42             }
43         }
44         return current;
45     }
46     
47     protected void setAttributes(FaceletContext ctx, Object JavaDoc instance) {
48         // Do nothing here, since UIXhtmlComponent sets up its properties
49
// differently than other UIComponents
50
}
51
52
53     /*
54     protected UIComponent applyToCurrent(FaceletContext ctx, UIComponent wrapped)
55             throws IOException, FacesException {
56         UIXhtmlComponent current = new UIXhtmlComponent();
57         current.setCreatedByFacelets();
58         current.setTag(tag.getQName());
59         String id = null;
60         TagAttribute[] attribs = tag.getAttributes().getAll();
61         for(int i = 0; i < attribs.length; i++) {
62             String qName = attribs[i].getQName();
63             if( attribs[i].isLiteral() ) {
64                 String value = attribs[i].getValue();
65                 if( qName.equals("id") )
66                     id = value;
67                 current.addStandardAttribute(qName, value);
68             }
69             else {
70                 // We don't always include the EL jars, so our
71                 // code has to use reflection to refer to
72                 // javax.el.ValueExpression
73                 Object value =
74                         attribs[i].getValueExpression(ctx, Object.class);
75                 current.addELValueExpression(qName, value);
76             }
77         }
78         // com.sun.facelets.tag.jsf.ComponentHandler.apply(-)
79         // assigns ids in a similar fashion
80         if( id != null ) {
81             current.setId( ctx.generateUniqueId(id) );
82         }
83         else {
84             UIViewRoot root =
85                     ComponentSupport.getViewRoot( ctx, wrapped );
86             if( root != null ) {
87                 current.setId( root.createUniqueId() );
88             }
89         }
90         return current;
91     }
92     */

93 }
94
Popular Tags