KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > faces > taglib > ParameterTag


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.faces.taglib;
17
18 import org.apache.cocoon.faces.FacesUtils;
19
20 import javax.faces.component.UIComponent;
21 import javax.faces.component.UIParameter;
22 import javax.faces.FacesException;
23
24 /**
25  * @version CVS $Id: ParameterTag.java 55441 2004-10-24 16:14:10Z cziegeler $
26  */

27 public class ParameterTag extends UIComponentTag {
28
29     private String JavaDoc name;
30     private String JavaDoc value;
31
32     public void setName(String JavaDoc name) {
33         this.name = name;
34     }
35
36     public void setValue(String JavaDoc value) {
37         this.value = value;
38     }
39
40     protected String JavaDoc getComponentType() {
41         return "javax.faces.Parameter";
42     }
43
44     protected String JavaDoc getRendererType() {
45         return null;
46     }
47
48     protected void setProperties(UIComponent component) {
49         super.setProperties(component);
50
51         UIParameter parameter;
52         try {
53             parameter = (UIParameter) component;
54         } catch (ClassCastException JavaDoc cce) {
55             throw new FacesException("Tag <" + getClass().getName() + "> expected UIParameter. " +
56                                      "Got <" + component.getClass().getName() + ">");
57         }
58
59         if (name != null) {
60             if (FacesUtils.isExpression(name)) {
61                 parameter.setValueBinding("name", createValueBinding(name));
62             } else {
63                 parameter.setName(name);
64             }
65         }
66
67         if (value != null) {
68             if (FacesUtils.isExpression(value)) {
69                 parameter.setValueBinding("value", createValueBinding(value));
70             } else {
71                 parameter.setValue(value);
72             }
73         }
74     }
75
76     public void recycle() {
77         super.recycle();
78         this.name = null;
79         this.value = null;
80     }
81 }
82
Popular Tags