View Javadoc

1   /*
2    * $Id: AbstractUITag.java 651946 2008-04-27 13:41:38Z apetrelli $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  package org.apache.struts2.views.jsp.ui;
23  
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  import javax.servlet.jsp.JspException;
28  import javax.servlet.jsp.tagext.DynamicAttributes;
29  
30  import org.apache.struts2.components.UIBean;
31  import org.apache.struts2.views.jsp.ComponentTagSupport;
32  
33  
34  /***
35   * Abstract base class for all UI tags.
36   *
37   */
38  public abstract class AbstractUITag extends ComponentTagSupport implements DynamicAttributes {
39      protected String cssClass;
40      protected String cssErrorClass;
41      protected String cssStyle;
42      protected String cssErrorStyle;
43      protected String title;
44      protected String disabled;
45      protected String label;
46      protected String labelSeparator;
47      protected String labelPosition;
48      protected String requiredposition;
49      protected String name;
50      protected String required;
51      protected String tabindex;
52      protected String value;
53      protected String template;
54      protected String theme;
55      protected String templateDir;
56      protected String onclick;
57      protected String ondblclick;
58      protected String onmousedown;
59      protected String onmouseup;
60      protected String onmouseover;
61      protected String onmousemove;
62      protected String onmouseout;
63      protected String onfocus;
64      protected String onblur;
65      protected String onkeypress;
66      protected String onkeydown;
67      protected String onkeyup;
68      protected String onselect;
69      protected String onchange;
70      protected String accesskey;
71      protected String id;
72  
73      protected String key;
74  
75      // tooltip attributes
76      protected String tooltip;
77      protected String tooltipConfig;
78      protected String javascriptTooltip;
79      protected String tooltipDelay;
80      protected String tooltipCssClass;
81      protected String tooltipIconPath;
82  
83      // dynamic attributes.
84      protected Map<String,Object> dynamicAttributes = new HashMap<String,Object>();
85  
86      protected void populateParams() {
87          super.populateParams();
88  
89          UIBean uiBean = (UIBean) component;
90          uiBean.setCssClass(cssClass);
91          uiBean.setCssStyle(cssStyle);
92          uiBean.setCssErrorClass(cssErrorClass);
93          uiBean.setCssErrorStyle(cssErrorStyle);
94          uiBean.setTitle(title);
95          uiBean.setDisabled(disabled);
96          uiBean.setLabel(label);
97          uiBean.setLabelSeparator(labelSeparator);
98          uiBean.setLabelposition(labelPosition);
99          uiBean.setRequiredposition(requiredposition);
100         uiBean.setName(name);
101         uiBean.setRequired(required);
102         uiBean.setTabindex(tabindex);
103         uiBean.setValue(value);
104         uiBean.setTemplate(template);
105         uiBean.setTheme(theme);
106         uiBean.setTemplateDir(templateDir);
107         uiBean.setOnclick(onclick);
108         uiBean.setOndblclick(ondblclick);
109         uiBean.setOnmousedown(onmousedown);
110         uiBean.setOnmouseup(onmouseup);
111         uiBean.setOnmouseover(onmouseover);
112         uiBean.setOnmousemove(onmousemove);
113         uiBean.setOnmouseout(onmouseout);
114         uiBean.setOnfocus(onfocus);
115         uiBean.setOnblur(onblur);
116         uiBean.setOnkeypress(onkeypress);
117         uiBean.setOnkeydown(onkeydown);
118         uiBean.setOnkeyup(onkeyup);
119         uiBean.setOnselect(onselect);
120         uiBean.setOnchange(onchange);
121         uiBean.setTooltip(tooltip);
122         uiBean.setTooltipConfig(tooltipConfig);
123         uiBean.setJavascriptTooltip(javascriptTooltip);
124         uiBean.setTooltipCssClass(tooltipCssClass);
125         uiBean.setTooltipDelay(tooltipDelay);
126         uiBean.setTooltipIconPath(tooltipIconPath);
127         uiBean.setAccesskey(accesskey);
128         uiBean.setKey(key);
129         uiBean.setId(id);
130 
131         uiBean.setDynamicAttributes(dynamicAttributes);
132     }
133 
134     public void setId(String id) {
135         this.id = id;
136     }
137 
138     public void setCssClass(String cssClass) {
139         this.cssClass = cssClass;
140     }
141 
142     public void setCssStyle(String cssStyle) {
143         this.cssStyle = cssStyle;
144     }
145 
146     public void setCssErrorClass(String cssErrorClass) {
147         this.cssErrorClass = cssErrorClass;
148     }
149 
150     public void setCssErrorStyle(String cssErrorStyle) {
151         this.cssErrorStyle = cssErrorStyle;
152     }
153 
154     public void setTitle(String title) {
155         this.title = title;
156     }
157 
158     public void setDisabled(String disabled) {
159         this.disabled = disabled;
160     }
161 
162     public void setLabel(String label) {
163         this.label = label;
164     }
165 
166     public void setLabelposition(String labelPosition) {
167         this.labelPosition = labelPosition;
168     }
169 
170     public void setRequiredposition(String requiredPosition) {
171         this.requiredposition = requiredPosition;
172     }
173 
174     public void setName(String name) {
175         this.name = name;
176     }
177 
178     public void setRequired(String required) {
179         this.required = required;
180     }
181 
182     public void setTabindex(String tabindex) {
183         this.tabindex = tabindex;
184     }
185 
186     public void setValue(String value) {
187         this.value = value;
188     }
189 
190     public void setTemplateDir(String templateDir) {
191         this.templateDir = templateDir;
192     }
193 
194     public void setTemplate(String template) {
195         this.template = template;
196     }
197 
198     public void setTheme(String theme) {
199         this.theme = theme;
200     }
201 
202     public void setOnclick(String onclick) {
203         this.onclick = onclick;
204     }
205 
206     public void setOndblclick(String ondblclick) {
207         this.ondblclick = ondblclick;
208     }
209 
210     public void setOnmousedown(String onmousedown) {
211         this.onmousedown = onmousedown;
212     }
213 
214     public void setOnmouseup(String onmouseup) {
215         this.onmouseup = onmouseup;
216     }
217 
218     public void setOnmouseover(String onmouseover) {
219         this.onmouseover = onmouseover;
220     }
221 
222     public void setOnmousemove(String onmousemove) {
223         this.onmousemove = onmousemove;
224     }
225 
226     public void setOnmouseout(String onmouseout) {
227         this.onmouseout = onmouseout;
228     }
229 
230     public void setOnfocus(String onfocus) {
231         this.onfocus = onfocus;
232     }
233 
234     public void setOnblur(String onblur) {
235         this.onblur = onblur;
236     }
237 
238     public void setOnkeypress(String onkeypress) {
239         this.onkeypress = onkeypress;
240     }
241 
242     public void setOnkeydown(String onkeydown) {
243         this.onkeydown = onkeydown;
244     }
245 
246     public void setOnkeyup(String onkeyup) {
247         this.onkeyup = onkeyup;
248     }
249 
250     public void setOnselect(String onselect) {
251         this.onselect = onselect;
252     }
253 
254     public void setOnchange(String onchange) {
255         this.onchange = onchange;
256     }
257 
258     public void setTooltip(String tooltip) {
259         this.tooltip = tooltip;
260     }
261 
262     public void setTooltipConfig(String tooltipConfig) {
263         this.tooltipConfig = tooltipConfig;
264     }
265 
266     public void setAccesskey(String accesskey) {
267         this.accesskey = accesskey;
268     }
269 
270     public void setKey(String key) {
271         this.key = key;
272     }
273 
274     public void setJavascriptTooltip(String javascriptTooltip) {
275         this.javascriptTooltip = javascriptTooltip;
276     }
277 
278     public void setTooltipCssClass(String tooltipCssClass) {
279         this.tooltipCssClass = tooltipCssClass;
280     }
281 
282     public void setTooltipDelay(String tooltipDelay) {
283         this.tooltipDelay = tooltipDelay;
284     }
285 
286     public void setTooltipIconPath(String tooltipIconPath) {
287         this.tooltipIconPath = tooltipIconPath;
288     }
289 
290     public void setLabelSeparator(String labelSeparator) {
291         this.labelSeparator = labelSeparator;
292     }
293 
294     public void setDynamicAttribute(String uri, String localName, Object value) throws JspException {
295         dynamicAttributes.put(localName, value);
296     }
297 }