1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package jakarta.faces.component;
20
21 import jakarta.el.ValueExpression;
22 import jakarta.faces.el.ValueBinding;
23
24 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
25 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
26
27
28
29
30
31
32
33
34 @JSFComponent(defaultRendererType = "jakarta.faces.Image")
35 public class UIGraphic extends UIComponentBase
36 {
37 public static final String COMPONENT_TYPE = "jakarta.faces.Graphic";
38 public static final String COMPONENT_FAMILY = "jakarta.faces.Graphic";
39
40 private static final String URL_PROPERTY = "url";
41 private static final String VALUE_PROPERTY = "value";
42
43
44
45
46 public UIGraphic()
47 {
48 setRendererType("jakarta.faces.Image");
49 }
50
51 @Override
52 public String getFamily()
53 {
54 return COMPONENT_FAMILY;
55 }
56
57
58
59
60 @JSFProperty
61 public String getUrl()
62 {
63 return (String) getValue();
64 }
65
66 public void setUrl(String url)
67 {
68 setValue(url);
69 }
70
71
72
73
74 @Override
75 public ValueBinding getValueBinding(String name)
76 {
77 if (URL_PROPERTY.equals(name))
78 {
79 return super.getValueBinding(VALUE_PROPERTY);
80 }
81 else
82 {
83 return super.getValueBinding(name);
84 }
85 }
86
87
88
89
90 @Override
91 public void setValueBinding(String name, ValueBinding binding)
92 {
93 if (URL_PROPERTY.equals(name))
94 {
95 super.setValueBinding(VALUE_PROPERTY, binding);
96 }
97 else
98 {
99 super.setValueBinding(name, binding);
100 }
101 }
102
103 @Override
104 public ValueExpression getValueExpression(String name)
105 {
106 if (URL_PROPERTY.equals(name))
107 {
108 return super.getValueExpression(VALUE_PROPERTY);
109 }
110 else
111 {
112 return super.getValueExpression(name);
113 }
114 }
115
116 @Override
117 public void setValueExpression(String name, ValueExpression binding)
118 {
119 if (URL_PROPERTY.equals(name))
120 {
121 super.setValueExpression(VALUE_PROPERTY, binding);
122 }
123 else
124 {
125 super.setValueExpression(name, binding);
126 }
127 }
128
129
130
131
132
133
134
135 @JSFProperty
136 public Object getValue()
137 {
138 return getStateHelper().eval(PropertyKeys.value);
139 }
140
141 public void setValue(Object value)
142 {
143 getStateHelper().put(PropertyKeys.value, value );
144 }
145
146 enum PropertyKeys
147 {
148 value
149 }
150 }