1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.custom.aliasbean;
20
21 import javax.faces.component.UIComponent;
22 import javax.servlet.jsp.JspException;
23
24 import org.apache.myfaces.shared_tomahawk.taglib.UIComponentTagBase;
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27
28
29
30
31
32 public class AliasBeanTag extends UIComponentTagBase {
33
34 private Log log = LogFactory.getLog(AliasBeanTag.class);
35
36 private String _alias;
37 private String _valueExpression;
38
39 public void release() {
40 super.release();
41
42 _alias=null;
43 _valueExpression=null;
44
45 }
46
47 protected void setProperties(UIComponent component) {
48 super.setProperties(component);
49
50 setValueBinding(component, "alias", _alias);
51 setStringProperty(component, "value", _valueExpression);
52 }
53
54 public String getComponentType() {
55 return AliasBean.COMPONENT_TYPE;
56 }
57
58 public String getRendererType() {
59 return null;
60 }
61
62 public void setAlias(String alias){
63 _alias = alias;
64 }
65
66 public void setValue(String valueExpression){
67 _valueExpression = valueExpression;
68 }
69
70 public int doStartTag() throws JspException
71 {
72 int retVal= super.doStartTag();
73
74 UIComponent comp = getComponentInstance();
75
76 if(comp instanceof AliasBean)
77 {
78 ((AliasBean) comp).makeAlias(getFacesContext());
79 }
80 else
81 {
82 log.warn("associated component is no aliasBean");
83 }
84
85 return retVal;
86 }
87
88 public int doEndTag() throws JspException
89 {
90 UIComponent comp = getComponentInstance();
91
92 if(comp instanceof AliasBean)
93 {
94 ((AliasBean) comp).removeAlias(getFacesContext());
95 }
96 else
97 {
98 log.warn("associated component is no aliasBean");
99 }
100
101 return super.doEndTag();
102 }
103 }