1 package org.andromda.cartridges.jsf.taglib;
2
3 import javax.faces.application.Application;
4 import javax.faces.component.UIComponent;
5 import javax.faces.context.FacesContext;
6 import javax.faces.el.ValueBinding;
7 import javax.faces.webapp.UIComponentTag;
8
9 import org.andromda.cartridges.jsf.component.JSFValidatorComponent;
10
11
12
13
14
15 public class JSFValidatorTag
16 extends UIComponentTag
17 {
18
19
20
21 private String client;
22
23
24
25
26
27
28 public void setClient(final String clientIn)
29 {
30 this.client = clientIn;
31 }
32
33
34
35
36
37
38 @Override
39 public void setProperties(final UIComponent component)
40 {
41 super.setProperties(component);
42
43 final String attributeName = JSFValidatorComponent.CLIENT;
44 final String attributeValue = this.client;
45 if (attributeValue != null)
46 {
47 if (UIComponentTag.isValueReference(this.client))
48 {
49 final FacesContext context = FacesContext.getCurrentInstance();
50 final Application application = context.getApplication();
51 final ValueBinding binding = application.createValueBinding(attributeValue);
52 component.setValueBinding(
53 attributeName,
54 binding);
55 }
56 else
57 {
58 component.getAttributes().put(
59 attributeName,
60 attributeValue);
61 }
62 }
63 final String validatorId = this.getId();
64 if (validatorId != null)
65 {
66 component.setId(validatorId);
67 }
68 }
69
70
71
72
73
74
75 @Override
76 public void release()
77 {
78 super.release();
79 this.client = null;
80 }
81
82
83
84
85 @Override
86 public String getRendererType()
87 {
88 return null;
89 }
90
91
92
93
94 private static final String COMPONENT_TYPE = JSFValidatorComponent.class.getName();
95
96
97
98
99
100 @Override
101 public String getComponentType()
102 {
103 return COMPONENT_TYPE;
104 }
105 }