KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > jsfext > event > handlers > basic > ComponentHandlers


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 /*
24  * ComponentHandlers.java
25  *
26  * Created on December 6, 2004, 11:06 PM
27  */

28 package com.sun.enterprise.tools.jsfext.event.handlers.basic;
29
30 import com.sun.enterprise.tools.jsfext.event.handlers.HandlerContext;
31
32 import java.util.List JavaDoc;
33
34 import javax.faces.component.UIComponent;
35
36
37 /**
38  * <p> This class contains
39  * {@link com.sun.enterprise.tools.jsfext.event.handlers.Handler}
40  * methods that perform component functions.</p>
41  *
42  * @author Ken Paulsen (ken.paulsen@sun.com)
43  */

44 public class ComponentHandlers {
45
46     /**
47      * <p> Default Constructor.</p>
48      */

49     public ComponentHandlers() {
50     }
51
52     /**
53      * <p> This handler returns the children of the given
54      * <code>UIComponent</code>.</p>
55      *
56      * <p> Input value: "parent" -- Type: <code>UIComponent</code></p>
57      *
58      * <p> Output value: "children" -- Type: <code>java.util.List</code></p>
59      * <p> Output value: "size" -- Type: <code>java.lang.Integer</code></p>
60      *
61      * @param context The HandlerContext.
62      */

63     public void getChildren(HandlerContext context) {
64     UIComponent parent = (UIComponent) context.getInputValue("parent");
65     List JavaDoc list = parent.getChildren();
66     context.setOutputValue("children", list);
67     context.setOutputValue("size", new Integer JavaDoc(list.size()));
68     }
69
70     /**
71      * <p> This handler sets a <code>UIComponent</code> attribute /
72      * property.</p>
73      *
74      * <p> Input value: "component" -- Type: <code>UIComponent</code></p>
75      * <p> Input value: "property" -- Type: <code>String</code></p>
76      * <p> Input value: "value" -- Type: <code>Object</code></p>
77      *
78      * @param context The HandlerContext.
79      */

80     public void setComponentProperty(HandlerContext context) {
81     UIComponent component =
82         (UIComponent) context.getInputValue("component");
83     String JavaDoc propName = (String JavaDoc) context.getInputValue("property");
84     Object JavaDoc value = context.getInputValue("value");
85
86     // Set the attribute or property value
87
component.getAttributes().put(propName, value);
88     }
89 }
90
Popular Tags