Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ComponentBase |
|
| 1.1565217391304348;1.157 |
1 | /* | |
2 | * Copyright 2007 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 1.0 (the | |
5 | * "License"); 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.opensource.org/licenses/ecl1.php | |
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, WITHOUT | |
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
13 | * License for the specific language governing permissions and limitations under | |
14 | * the License. | |
15 | */ | |
16 | package org.kuali.rice.kns.uif.core; | |
17 | ||
18 | import java.util.ArrayList; | |
19 | import java.util.Arrays; | |
20 | import java.util.HashMap; | |
21 | import java.util.HashSet; | |
22 | import java.util.List; | |
23 | import java.util.Map; | |
24 | import java.util.Set; | |
25 | ||
26 | import org.apache.commons.lang.StringUtils; | |
27 | import org.kuali.rice.kns.uif.CssConstants; | |
28 | import org.kuali.rice.kns.uif.UifConstants.ViewStatus; | |
29 | import org.kuali.rice.kns.uif.UifPropertyPaths; | |
30 | import org.kuali.rice.kns.uif.container.View; | |
31 | import org.kuali.rice.kns.uif.modifier.ComponentModifier; | |
32 | ||
33 | /** | |
34 | * Base implementation of <code>Component</code> which other component | |
35 | * implementations should extend | |
36 | * | |
37 | * <p> | |
38 | * Provides base component properties such as id and template. Also provides | |
39 | * default implementation for the <code>ScriptEventSupport</code> and | |
40 | * <code>Ordered</code> interfaces. By default no script events are supported. | |
41 | * </p> | |
42 | * | |
43 | * <p> | |
44 | * <code>ComponentBase</code> also provides properties for a | |
45 | * <code>ComponentDecorator</code> and a List of | |
46 | * </code>ComponentInitializers</code> | |
47 | * </p> | |
48 | * | |
49 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
50 | */ | |
51 | public abstract class ComponentBase implements Component, ScriptEventSupport { | |
52 | private static final long serialVersionUID = -4449335748129894350L; | |
53 | ||
54 | private String id; | |
55 | private String template; | |
56 | private String title; | |
57 | ||
58 | private boolean render; | |
59 | private String conditionalRender; | |
60 | ||
61 | private boolean hidden; | |
62 | ||
63 | private boolean readOnly; | |
64 | private String conditionalReadOnly; | |
65 | ||
66 | private Boolean required; | |
67 | private String conditionalRequired; | |
68 | ||
69 | private String align; | |
70 | private String valign; | |
71 | private String width; | |
72 | ||
73 | private int colSpan; | |
74 | private String conditionalColSpan; | |
75 | ||
76 | private int rowSpan; | |
77 | private String conditionalRowSpan; | |
78 | ||
79 | private String style; | |
80 | private List<String> styleClasses; | |
81 | ||
82 | private int order; | |
83 | ||
84 | private String onLoadScript; | |
85 | private String onUnloadScript; | |
86 | private String onCloseScript; | |
87 | private String onBlurScript; | |
88 | private String onChangeScript; | |
89 | private String onClickScript; | |
90 | private String onDblClickScript; | |
91 | private String onFocusScript; | |
92 | private String onSubmitScript; | |
93 | private String onKeyPressScript; | |
94 | private String onKeyUpScript; | |
95 | private String onKeyDownScript; | |
96 | private String onMouseOverScript; | |
97 | private String onMouseOutScript; | |
98 | private String onMouseUpScript; | |
99 | private String onMouseDownScript; | |
100 | private String onMouseMoveScript; | |
101 | private String onDocumentReadyScript; | |
102 | ||
103 | private List<ComponentModifier> componentModifiers; | |
104 | ||
105 | private Map<String, String> componentOptions; | |
106 | ||
107 | @ReferenceCopy(newCollectionInstance = true) | |
108 | private transient Map<String, Object> context; | |
109 | ||
110 | private List<PropertyReplacer> propertyReplacers; | |
111 | ||
112 | 0 | public ComponentBase() { |
113 | 0 | order = 0; |
114 | 0 | colSpan = 1; |
115 | 0 | rowSpan = 1; |
116 | ||
117 | 0 | render = true; |
118 | ||
119 | 0 | styleClasses = new ArrayList<String>(); |
120 | 0 | componentModifiers = new ArrayList<ComponentModifier>(); |
121 | 0 | componentOptions = new HashMap<String, String>(); |
122 | 0 | context = new HashMap<String, Object>(); |
123 | 0 | propertyReplacers = new ArrayList<PropertyReplacer>(); |
124 | 0 | } |
125 | ||
126 | /** | |
127 | * The following initialization is performed: | |
128 | * | |
129 | * <ul> | |
130 | * </ul> | |
131 | * | |
132 | * @see org.kuali.rice.kns.uif.core.ComponentBase#performInitialization(org.kuali.rice.kns.uif.container.View) | |
133 | */ | |
134 | public void performInitialization(View view) { | |
135 | ||
136 | 0 | } |
137 | ||
138 | /** | |
139 | * The following updates are done here: | |
140 | * | |
141 | * <ul> | |
142 | * <li></li> | |
143 | * </ul> | |
144 | * | |
145 | * @see org.kuali.rice.kns.uif.core.Component#performApplyModel(org.kuali.rice.kns.uif.container.View, | |
146 | * java.lang.Object) | |
147 | */ | |
148 | public void performApplyModel(View view, Object model) { | |
149 | ||
150 | 0 | } |
151 | ||
152 | /** | |
153 | * The following finalization is done here: | |
154 | * | |
155 | * <ul> | |
156 | * <li>If any of the style properties were given, sets the style string on | |
157 | * the style property</li> | |
158 | * <li>Setup the decorator chain (if component has decorators) for rendering | |
159 | * </li> | |
160 | * </ul> | |
161 | * | |
162 | * @see org.kuali.rice.kns.uif.core.Component#performFinalize(org.kuali.rice.kns.uif.container.View, | |
163 | * java.lang.Object, org.kuali.rice.kns.uif.core.Component) | |
164 | */ | |
165 | public void performFinalize(View view, Object model, Component parent) { | |
166 | 0 | if (!ViewStatus.FINAL.equals(view.getViewStatus())) { |
167 | // add the align, valign, and width settings to style | |
168 | 0 | if (StringUtils.isNotBlank(getAlign()) && !StringUtils.contains(getStyle(), CssConstants.TEXT_ALIGN)) { |
169 | 0 | appendToStyle(CssConstants.TEXT_ALIGN + getAlign() + ";"); |
170 | } | |
171 | ||
172 | 0 | if (StringUtils.isNotBlank(getValign()) && !StringUtils.contains(getStyle(), CssConstants.VERTICAL_ALIGN)) { |
173 | 0 | appendToStyle(CssConstants.VERTICAL_ALIGN + getValign() + ";"); |
174 | } | |
175 | ||
176 | 0 | if (StringUtils.isNotBlank(getWidth()) && !StringUtils.contains(getStyle(), CssConstants.WIDTH)) { |
177 | 0 | appendToStyle(CssConstants.WIDTH + getWidth() + ";"); |
178 | } | |
179 | } | |
180 | 0 | } |
181 | ||
182 | /** | |
183 | * @see org.kuali.rice.kns.uif.core.Component#getNestedComponents() | |
184 | */ | |
185 | @Override | |
186 | public List<Component> getNestedComponents() { | |
187 | 0 | List<Component> components = new ArrayList<Component>(); |
188 | ||
189 | 0 | return components; |
190 | } | |
191 | ||
192 | /** | |
193 | * Set of property names for the component base for which on the property | |
194 | * value reference should be copied. Subclasses can override this but should | |
195 | * include a call to super | |
196 | * | |
197 | * @see org.kuali.rice.kns.uif.core.Component#getPropertiesForReferenceCopy() | |
198 | */ | |
199 | public Set<String> getPropertiesForReferenceCopy() { | |
200 | 0 | Set<String> refCopyProperties = new HashSet<String>(); |
201 | ||
202 | 0 | refCopyProperties.add(UifPropertyPaths.COMPONENT_MODIFIERS); |
203 | 0 | refCopyProperties.add(UifPropertyPaths.CONTEXT); |
204 | ||
205 | 0 | return refCopyProperties; |
206 | } | |
207 | ||
208 | /** | |
209 | * @see org.kuali.rice.kns.uif.core.Component#getId() | |
210 | */ | |
211 | public String getId() { | |
212 | 0 | return this.id; |
213 | } | |
214 | ||
215 | /** | |
216 | * @see org.kuali.rice.kns.uif.core.Component#setId(java.lang.String) | |
217 | */ | |
218 | public void setId(String id) { | |
219 | 0 | this.id = id; |
220 | 0 | } |
221 | ||
222 | /** | |
223 | * @see org.kuali.rice.kns.uif.core.Component#getTemplate() | |
224 | */ | |
225 | public String getTemplate() { | |
226 | 0 | return this.template; |
227 | } | |
228 | ||
229 | /** | |
230 | * @see org.kuali.rice.kns.uif.core.Component#setTemplate(java.lang.String) | |
231 | */ | |
232 | public void setTemplate(String template) { | |
233 | 0 | this.template = template; |
234 | 0 | } |
235 | ||
236 | /** | |
237 | * @see org.kuali.rice.kns.uif.core.Component#getTitle() | |
238 | */ | |
239 | public String getTitle() { | |
240 | 0 | return this.title; |
241 | } | |
242 | ||
243 | /** | |
244 | * @see org.kuali.rice.kns.uif.core.Component#setTitle(java.lang.String) | |
245 | */ | |
246 | public void setTitle(String title) { | |
247 | 0 | this.title = title; |
248 | 0 | } |
249 | ||
250 | /** | |
251 | * @see org.kuali.rice.kns.uif.core.Component#isHidden() | |
252 | */ | |
253 | public boolean isHidden() { | |
254 | 0 | return this.hidden; |
255 | } | |
256 | ||
257 | /** | |
258 | * @see org.kuali.rice.kns.uif.core.Component#setHidden(boolean) | |
259 | */ | |
260 | public void setHidden(boolean hidden) { | |
261 | 0 | this.hidden = hidden; |
262 | 0 | } |
263 | ||
264 | /** | |
265 | * @see org.kuali.rice.kns.uif.core.Component#isReadOnly() | |
266 | */ | |
267 | public boolean isReadOnly() { | |
268 | 0 | return this.readOnly; |
269 | } | |
270 | ||
271 | /** | |
272 | * @see org.kuali.rice.kns.uif.core.Component#setReadOnly(boolean) | |
273 | */ | |
274 | public void setReadOnly(boolean readOnly) { | |
275 | 0 | this.readOnly = readOnly; |
276 | 0 | } |
277 | ||
278 | /** | |
279 | * @see org.kuali.rice.kns.uif.core.Component#getConditionalReadOnly() | |
280 | */ | |
281 | public String getConditionalReadOnly() { | |
282 | 0 | return this.conditionalReadOnly; |
283 | } | |
284 | ||
285 | /** | |
286 | * @see org.kuali.rice.kns.uif.core.Component#setConditionalReadOnly(java.lang.String) | |
287 | */ | |
288 | public void setConditionalReadOnly(String conditionalReadOnly) { | |
289 | 0 | this.conditionalReadOnly = conditionalReadOnly; |
290 | 0 | } |
291 | ||
292 | /** | |
293 | * @see org.kuali.rice.kns.uif.core.Component#getRequired() | |
294 | */ | |
295 | public Boolean getRequired() { | |
296 | 0 | return this.required; |
297 | } | |
298 | ||
299 | /** | |
300 | * @see org.kuali.rice.kns.uif.core.Component#setRequired(java.lang.Boolean) | |
301 | */ | |
302 | public void setRequired(Boolean required) { | |
303 | 0 | this.required = required; |
304 | 0 | } |
305 | ||
306 | /** | |
307 | * Expression language string for conditionally setting the required | |
308 | * property | |
309 | * | |
310 | * @return String el that should evaluate to boolean | |
311 | */ | |
312 | public String getConditionalRequired() { | |
313 | 0 | return this.conditionalRequired; |
314 | } | |
315 | ||
316 | /** | |
317 | * Setter for the conditional required string | |
318 | * | |
319 | * @param conditionalRequired | |
320 | */ | |
321 | public void setConditionalRequired(String conditionalRequired) { | |
322 | 0 | this.conditionalRequired = conditionalRequired; |
323 | 0 | } |
324 | ||
325 | /** | |
326 | * @see org.kuali.rice.kns.uif.core.Component#isRender() | |
327 | */ | |
328 | public boolean isRender() { | |
329 | 0 | return this.render; |
330 | } | |
331 | ||
332 | /** | |
333 | * @see org.kuali.rice.kns.uif.core.Component#setRender(boolean) | |
334 | */ | |
335 | public void setRender(boolean render) { | |
336 | 0 | this.render = render; |
337 | 0 | } |
338 | ||
339 | /** | |
340 | * Expression language string for conditionally setting the render property | |
341 | * | |
342 | * @return String el that should evaluate to boolean | |
343 | */ | |
344 | public String getConditionalRender() { | |
345 | 0 | return this.conditionalRender; |
346 | } | |
347 | ||
348 | /** | |
349 | * Setter for the conditional render string | |
350 | * | |
351 | * @param conditionalRender | |
352 | */ | |
353 | public void setConditionalRender(String conditionalRender) { | |
354 | 0 | this.conditionalRender = conditionalRender; |
355 | 0 | } |
356 | ||
357 | /** | |
358 | * @see org.kuali.rice.kns.uif.core.Component#getColSpan() | |
359 | */ | |
360 | public int getColSpan() { | |
361 | 0 | return this.colSpan; |
362 | } | |
363 | ||
364 | /** | |
365 | * @see org.kuali.rice.kns.uif.core.Component#setColSpan(int) | |
366 | */ | |
367 | public void setColSpan(int colSpan) { | |
368 | 0 | this.colSpan = colSpan; |
369 | 0 | } |
370 | ||
371 | /** | |
372 | * Expression language string for conditionally setting the colSpan property | |
373 | * | |
374 | * @return String el that should evaluate to int | |
375 | */ | |
376 | public String getConditionalColSpan() { | |
377 | 0 | return this.conditionalColSpan; |
378 | } | |
379 | ||
380 | /** | |
381 | * Setter for the conditional colSpan string | |
382 | * | |
383 | * @param conditionalColSpan | |
384 | */ | |
385 | public void setConditionalColSpan(String conditionalColSpan) { | |
386 | 0 | this.conditionalColSpan = conditionalColSpan; |
387 | 0 | } |
388 | ||
389 | /** | |
390 | * @see org.kuali.rice.kns.uif.core.Component#getRowSpan() | |
391 | */ | |
392 | public int getRowSpan() { | |
393 | 0 | return this.rowSpan; |
394 | } | |
395 | ||
396 | /** | |
397 | * @see org.kuali.rice.kns.uif.core.Component#setRowSpan(int) | |
398 | */ | |
399 | public void setRowSpan(int rowSpan) { | |
400 | 0 | this.rowSpan = rowSpan; |
401 | 0 | } |
402 | ||
403 | /** | |
404 | * Expression language string for conditionally setting the rowSpan property | |
405 | * | |
406 | * @return String el that should evaluate to int | |
407 | */ | |
408 | public String getConditionalRowSpan() { | |
409 | 0 | return this.conditionalRowSpan; |
410 | } | |
411 | ||
412 | /** | |
413 | * Setter for the conditional rowSpan string | |
414 | * | |
415 | * @param conditionalRowSpan | |
416 | */ | |
417 | public void setConditionalRowSpan(String conditionalRowSpan) { | |
418 | 0 | this.conditionalRowSpan = conditionalRowSpan; |
419 | 0 | } |
420 | ||
421 | /** | |
422 | * Horizontal alignment of the component within its container | |
423 | * | |
424 | * <p> | |
425 | * All components belong to a <code>Container</code> and are placed using a | |
426 | * <code>LayoutManager</code>. This property specifies how the component | |
427 | * should be aligned horizontally within the container. During the finalize | |
428 | * phase the CSS text-align style will be created for the align setting. | |
429 | * </p> | |
430 | * | |
431 | * @return String horizontal align | |
432 | * @see org.kuali.rice.kns.uif.CssConstants.TextAligns | |
433 | */ | |
434 | public String getAlign() { | |
435 | 0 | return this.align; |
436 | } | |
437 | ||
438 | /** | |
439 | * Sets the components horizontal alignment | |
440 | * | |
441 | * @param align | |
442 | */ | |
443 | public void setAlign(String align) { | |
444 | 0 | this.align = align; |
445 | 0 | } |
446 | ||
447 | /** | |
448 | * Vertical alignment of the component within its container | |
449 | * | |
450 | * <p> | |
451 | * All components belong to a <code>Container</code> and are placed using a | |
452 | * <code>LayoutManager</code>. This property specifies how the component | |
453 | * should be aligned vertically within the container. During the finalize | |
454 | * phase the CSS vertical-align style will be created for the valign | |
455 | * setting. | |
456 | * </p> | |
457 | * | |
458 | * @return String vertical align | |
459 | * @see org.kuali.rice.kns.uif.CssConstants.VerticalAligns | |
460 | */ | |
461 | public String getValign() { | |
462 | 0 | return this.valign; |
463 | } | |
464 | ||
465 | /** | |
466 | * Setter for the component's vertical align | |
467 | * | |
468 | * @param valign | |
469 | */ | |
470 | public void setValign(String valign) { | |
471 | 0 | this.valign = valign; |
472 | 0 | } |
473 | ||
474 | /** | |
475 | * Width the component should take up in the container | |
476 | * | |
477 | * <p> | |
478 | * All components belong to a <code>Container</code> and are placed using a | |
479 | * <code>LayoutManager</code>. This property specifies a width the component | |
480 | * should take up in the Container. This is not applicable for all layout | |
481 | * managers. During the finalize phase the CSS width style will be created | |
482 | * for the width setting. | |
483 | * </p> | |
484 | * | |
485 | * <p> | |
486 | * e.g. '30%', '55px' | |
487 | * </p> | |
488 | * | |
489 | * @return String width string | |
490 | */ | |
491 | public String getWidth() { | |
492 | 0 | return this.width; |
493 | } | |
494 | ||
495 | /** | |
496 | * Setter for the components width | |
497 | * | |
498 | * @param width | |
499 | */ | |
500 | public void setWidth(String width) { | |
501 | 0 | this.width = width; |
502 | 0 | } |
503 | ||
504 | /** | |
505 | * @see org.kuali.rice.kns.uif.core.Component#getStyle() | |
506 | */ | |
507 | public String getStyle() { | |
508 | 0 | return this.style; |
509 | } | |
510 | ||
511 | /** | |
512 | * @see org.kuali.rice.kns.uif.core.Component#setStyle(java.lang.String) | |
513 | */ | |
514 | public void setStyle(String style) { | |
515 | 0 | this.style = style; |
516 | 0 | } |
517 | ||
518 | /** | |
519 | * @see org.kuali.rice.kns.uif.core.Component#getStyleClasses() | |
520 | */ | |
521 | public List<String> getStyleClasses() { | |
522 | 0 | return this.styleClasses; |
523 | } | |
524 | ||
525 | /** | |
526 | * @see org.kuali.rice.kns.uif.core.Component#setStyleClasses(java.util.List) | |
527 | */ | |
528 | public void setStyleClasses(List<String> styleClasses) { | |
529 | 0 | this.styleClasses = styleClasses; |
530 | 0 | } |
531 | ||
532 | /** | |
533 | * Builds the HTML class attribute string by combining the styleClasses list | |
534 | * with a space delimiter | |
535 | * | |
536 | * @return String class attribute string | |
537 | */ | |
538 | public String getStyleClassesAsString() { | |
539 | 0 | if (styleClasses != null) { |
540 | 0 | return StringUtils.join(styleClasses, " "); |
541 | } | |
542 | ||
543 | 0 | return ""; |
544 | } | |
545 | ||
546 | /** | |
547 | * Sets the styleClasses list from the given string that has the classes | |
548 | * delimited by space. This is a convenience for configuration. If a child | |
549 | * bean needs to inherit the classes from the parent, it should configure as | |
550 | * a list and use merge="true" | |
551 | * | |
552 | * @param styleClasses | |
553 | */ | |
554 | public void setStyleClasses(String styleClasses) { | |
555 | 0 | String[] classes = StringUtils.split(styleClasses); |
556 | 0 | this.styleClasses = Arrays.asList(classes); |
557 | 0 | } |
558 | ||
559 | /** | |
560 | * @see org.kuali.rice.kns.uif.core.Component#addStyleClass(java.lang.String) | |
561 | */ | |
562 | public void addStyleClass(String styleClass) { | |
563 | 0 | if (!styleClasses.contains(styleClass)) { |
564 | 0 | styleClasses.add(styleClass); |
565 | } | |
566 | 0 | } |
567 | ||
568 | /** | |
569 | * @see org.kuali.rice.kns.uif.Component#appendToStyle(java.lang.String) | |
570 | */ | |
571 | public void appendToStyle(String styleRules) { | |
572 | 0 | if (style == null) { |
573 | 0 | style = ""; |
574 | } | |
575 | 0 | style = style + styleRules; |
576 | 0 | } |
577 | ||
578 | /** | |
579 | * @see org.kuali.rice.kns.uif.core.Component#getComponentModifiers() | |
580 | */ | |
581 | public List<ComponentModifier> getComponentModifiers() { | |
582 | 0 | return this.componentModifiers; |
583 | } | |
584 | ||
585 | /** | |
586 | * @see org.kuali.rice.kns.uif.core.Component#setComponentModifiers(java.util.List) | |
587 | */ | |
588 | public void setComponentModifiers(List<ComponentModifier> componentModifiers) { | |
589 | 0 | this.componentModifiers = componentModifiers; |
590 | 0 | } |
591 | ||
592 | /** | |
593 | * @see org.kuali.rice.kns.uif.core.Component#getContext() | |
594 | */ | |
595 | public Map<String, Object> getContext() { | |
596 | 0 | return this.context; |
597 | } | |
598 | ||
599 | /** | |
600 | * @see org.kuali.rice.kns.uif.core.Component#setContext(java.util.Map) | |
601 | */ | |
602 | public void setContext(Map<String, Object> context) { | |
603 | 0 | this.context = context; |
604 | 0 | } |
605 | ||
606 | /** | |
607 | * @see org.kuali.rice.kns.uif.core.Component#pushObjectToContext(java.lang.String, | |
608 | * java.lang.Object) | |
609 | */ | |
610 | public void pushObjectToContext(String objectName, Object object) { | |
611 | 0 | if (this.context == null) { |
612 | 0 | this.context = new HashMap<String, Object>(); |
613 | } | |
614 | ||
615 | 0 | this.context.put(objectName, object); |
616 | 0 | } |
617 | ||
618 | /** | |
619 | * @see org.kuali.rice.kns.uif.core.Component#getPropertyReplacers() | |
620 | */ | |
621 | public List<PropertyReplacer> getPropertyReplacers() { | |
622 | 0 | return this.propertyReplacers; |
623 | } | |
624 | ||
625 | /** | |
626 | * @see org.kuali.rice.kns.uif.core.Component#setPropertyReplacers(java.util.List) | |
627 | */ | |
628 | public void setPropertyReplacers(List<PropertyReplacer> propertyReplacers) { | |
629 | 0 | this.propertyReplacers = propertyReplacers; |
630 | 0 | } |
631 | ||
632 | /** | |
633 | * @see org.springframework.core.Ordered#getOrder() | |
634 | */ | |
635 | public int getOrder() { | |
636 | 0 | return this.order; |
637 | } | |
638 | ||
639 | /** | |
640 | * Setter for the component's order | |
641 | * | |
642 | * @param order | |
643 | */ | |
644 | public void setOrder(int order) { | |
645 | 0 | this.order = order; |
646 | 0 | } |
647 | ||
648 | /** | |
649 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnLoad() | |
650 | */ | |
651 | public boolean getSupportsOnLoad() { | |
652 | 0 | return false; |
653 | } | |
654 | ||
655 | /** | |
656 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnLoadScript() | |
657 | */ | |
658 | public String getOnLoadScript() { | |
659 | 0 | return onLoadScript; |
660 | } | |
661 | ||
662 | /** | |
663 | * Setter for the components onLoad script | |
664 | * | |
665 | * @param onLoadScript | |
666 | */ | |
667 | public void setOnLoadScript(String onLoadScript) { | |
668 | 0 | this.onLoadScript = onLoadScript; |
669 | 0 | } |
670 | ||
671 | /** | |
672 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnDocumentReady() | |
673 | */ | |
674 | public boolean getSupportsOnDocumentReady() { | |
675 | 0 | return false; |
676 | } | |
677 | ||
678 | /** | |
679 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnDocumentReadyScript() | |
680 | */ | |
681 | public String getOnDocumentReadyScript() { | |
682 | 0 | return onDocumentReadyScript; |
683 | } | |
684 | ||
685 | /** | |
686 | * Setter for the components onDocumentReady script | |
687 | * | |
688 | * @param onDocumentReadyScript | |
689 | */ | |
690 | public void setOnDocumentReadyScript(String onDocumentReadyScript) { | |
691 | 0 | this.onDocumentReadyScript = onDocumentReadyScript; |
692 | 0 | } |
693 | ||
694 | /** | |
695 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnUnload() | |
696 | */ | |
697 | public boolean getSupportsOnUnload() { | |
698 | 0 | return false; |
699 | } | |
700 | ||
701 | /** | |
702 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnUnloadScript() | |
703 | */ | |
704 | public String getOnUnloadScript() { | |
705 | 0 | return onUnloadScript; |
706 | } | |
707 | ||
708 | /** | |
709 | * Setter for the components onUnload script | |
710 | * | |
711 | * @param onUnloadScript | |
712 | */ | |
713 | public void setOnUnloadScript(String onUnloadScript) { | |
714 | 0 | this.onUnloadScript = onUnloadScript; |
715 | 0 | } |
716 | ||
717 | /** | |
718 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnClose() | |
719 | */ | |
720 | public boolean getSupportsOnClose() { | |
721 | 0 | return false; |
722 | } | |
723 | ||
724 | /** | |
725 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnCloseScript() | |
726 | */ | |
727 | public String getOnCloseScript() { | |
728 | 0 | return onCloseScript; |
729 | } | |
730 | ||
731 | /** | |
732 | * Setter for the components onClose script | |
733 | * | |
734 | * @param onCloseScript | |
735 | */ | |
736 | public void setOnCloseScript(String onCloseScript) { | |
737 | 0 | this.onCloseScript = onCloseScript; |
738 | 0 | } |
739 | ||
740 | /** | |
741 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnBlur() | |
742 | */ | |
743 | public boolean getSupportsOnBlur() { | |
744 | 0 | return false; |
745 | } | |
746 | ||
747 | /** | |
748 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnBlurScript() | |
749 | */ | |
750 | public String getOnBlurScript() { | |
751 | 0 | return onBlurScript; |
752 | } | |
753 | ||
754 | /** | |
755 | * Setter for the components onBlur script | |
756 | * | |
757 | * @param onBlurScript | |
758 | */ | |
759 | public void setOnBlurScript(String onBlurScript) { | |
760 | 0 | this.onBlurScript = onBlurScript; |
761 | 0 | } |
762 | ||
763 | /** | |
764 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnChange() | |
765 | */ | |
766 | public boolean getSupportsOnChange() { | |
767 | 0 | return false; |
768 | } | |
769 | ||
770 | /** | |
771 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnChangeScript() | |
772 | */ | |
773 | public String getOnChangeScript() { | |
774 | 0 | return onChangeScript; |
775 | } | |
776 | ||
777 | /** | |
778 | * Setter for the components onChange script | |
779 | * | |
780 | * @param onChangeScript | |
781 | */ | |
782 | public void setOnChangeScript(String onChangeScript) { | |
783 | 0 | this.onChangeScript = onChangeScript; |
784 | 0 | } |
785 | ||
786 | /** | |
787 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnClick() | |
788 | */ | |
789 | public boolean getSupportsOnClick() { | |
790 | 0 | return false; |
791 | } | |
792 | ||
793 | /** | |
794 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnClickScript() | |
795 | */ | |
796 | public String getOnClickScript() { | |
797 | 0 | return onClickScript; |
798 | } | |
799 | ||
800 | /** | |
801 | * Setter for the components onClick script | |
802 | * | |
803 | * @param onClickScript | |
804 | */ | |
805 | public void setOnClickScript(String onClickScript) { | |
806 | 0 | this.onClickScript = onClickScript; |
807 | 0 | } |
808 | ||
809 | /** | |
810 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnDblClick() | |
811 | */ | |
812 | public boolean getSupportsOnDblClick() { | |
813 | 0 | return false; |
814 | } | |
815 | ||
816 | /** | |
817 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnDblClickScript() | |
818 | */ | |
819 | public String getOnDblClickScript() { | |
820 | 0 | return onDblClickScript; |
821 | } | |
822 | ||
823 | /** | |
824 | * Setter for the components onDblClick script | |
825 | * | |
826 | * @param onDblClickScript | |
827 | */ | |
828 | public void setOnDblClickScript(String onDblClickScript) { | |
829 | 0 | this.onDblClickScript = onDblClickScript; |
830 | 0 | } |
831 | ||
832 | /** | |
833 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnFocus() | |
834 | */ | |
835 | public boolean getSupportsOnFocus() { | |
836 | 0 | return false; |
837 | } | |
838 | ||
839 | /** | |
840 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnFocusScript() | |
841 | */ | |
842 | public String getOnFocusScript() { | |
843 | 0 | return onFocusScript; |
844 | } | |
845 | ||
846 | /** | |
847 | * Setter for the components onFocus script | |
848 | * | |
849 | * @param onFocusScript | |
850 | */ | |
851 | public void setOnFocusScript(String onFocusScript) { | |
852 | 0 | this.onFocusScript = onFocusScript; |
853 | 0 | } |
854 | ||
855 | /** | |
856 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnSubmit() | |
857 | */ | |
858 | public boolean getSupportsOnSubmit() { | |
859 | 0 | return false; |
860 | } | |
861 | ||
862 | /** | |
863 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnSubmitScript() | |
864 | */ | |
865 | public String getOnSubmitScript() { | |
866 | 0 | return onSubmitScript; |
867 | } | |
868 | ||
869 | /** | |
870 | * Setter for the components onSubmit script | |
871 | * | |
872 | * @param onSubmitScript | |
873 | */ | |
874 | public void setOnSubmitScript(String onSubmitScript) { | |
875 | 0 | this.onSubmitScript = onSubmitScript; |
876 | 0 | } |
877 | ||
878 | /** | |
879 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnKeyPress() | |
880 | */ | |
881 | public boolean getSupportsOnKeyPress() { | |
882 | 0 | return false; |
883 | } | |
884 | ||
885 | /** | |
886 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnKeyPressScript() | |
887 | */ | |
888 | public String getOnKeyPressScript() { | |
889 | 0 | return onKeyPressScript; |
890 | } | |
891 | ||
892 | /** | |
893 | * Setter for the components onKeyPress script | |
894 | * | |
895 | * @param onKeyPressScript | |
896 | */ | |
897 | public void setOnKeyPressScript(String onKeyPressScript) { | |
898 | 0 | this.onKeyPressScript = onKeyPressScript; |
899 | 0 | } |
900 | ||
901 | /** | |
902 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnKeyUp() | |
903 | */ | |
904 | public boolean getSupportsOnKeyUp() { | |
905 | 0 | return false; |
906 | } | |
907 | ||
908 | /** | |
909 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnKeyUpScript() | |
910 | */ | |
911 | public String getOnKeyUpScript() { | |
912 | 0 | return onKeyUpScript; |
913 | } | |
914 | ||
915 | /** | |
916 | * Setter for the components onKeyUp script | |
917 | * | |
918 | * @param onKeyUpScript | |
919 | */ | |
920 | public void setOnKeyUpScript(String onKeyUpScript) { | |
921 | 0 | this.onKeyUpScript = onKeyUpScript; |
922 | 0 | } |
923 | ||
924 | /** | |
925 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnKeyDown() | |
926 | */ | |
927 | public boolean getSupportsOnKeyDown() { | |
928 | 0 | return false; |
929 | } | |
930 | ||
931 | /** | |
932 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnKeyDownScript() | |
933 | */ | |
934 | public String getOnKeyDownScript() { | |
935 | 0 | return onKeyDownScript; |
936 | } | |
937 | ||
938 | /** | |
939 | * Setter for the components onKeyDown script | |
940 | * | |
941 | * @param onKeyDownScript | |
942 | */ | |
943 | public void setOnKeyDownScript(String onKeyDownScript) { | |
944 | 0 | this.onKeyDownScript = onKeyDownScript; |
945 | 0 | } |
946 | ||
947 | /** | |
948 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnMouseOver() | |
949 | */ | |
950 | public boolean getSupportsOnMouseOver() { | |
951 | 0 | return false; |
952 | } | |
953 | ||
954 | /** | |
955 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnMouseOverScript() | |
956 | */ | |
957 | public String getOnMouseOverScript() { | |
958 | 0 | return onMouseOverScript; |
959 | } | |
960 | ||
961 | /** | |
962 | * Setter for the components onMouseOver script | |
963 | * | |
964 | * @param onMouseOverScript | |
965 | */ | |
966 | public void setOnMouseOverScript(String onMouseOverScript) { | |
967 | 0 | this.onMouseOverScript = onMouseOverScript; |
968 | 0 | } |
969 | ||
970 | /** | |
971 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnMouseOut() | |
972 | */ | |
973 | public boolean getSupportsOnMouseOut() { | |
974 | 0 | return false; |
975 | } | |
976 | ||
977 | /** | |
978 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnMouseOutScript() | |
979 | */ | |
980 | public String getOnMouseOutScript() { | |
981 | 0 | return onMouseOutScript; |
982 | } | |
983 | ||
984 | /** | |
985 | * Setter for the components onMouseOut script | |
986 | * | |
987 | * @param onMouseOutScript | |
988 | */ | |
989 | public void setOnMouseOutScript(String onMouseOutScript) { | |
990 | 0 | this.onMouseOutScript = onMouseOutScript; |
991 | 0 | } |
992 | ||
993 | /** | |
994 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnMouseUp() | |
995 | */ | |
996 | public boolean getSupportsOnMouseUp() { | |
997 | 0 | return false; |
998 | } | |
999 | ||
1000 | /** | |
1001 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnMouseUpScript() | |
1002 | */ | |
1003 | public String getOnMouseUpScript() { | |
1004 | 0 | return onMouseUpScript; |
1005 | } | |
1006 | ||
1007 | /** | |
1008 | * Setter for the components onMouseUp script | |
1009 | * | |
1010 | * @param onMouseUpScript | |
1011 | */ | |
1012 | public void setOnMouseUpScript(String onMouseUpScript) { | |
1013 | 0 | this.onMouseUpScript = onMouseUpScript; |
1014 | 0 | } |
1015 | ||
1016 | /** | |
1017 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnMouseDown() | |
1018 | */ | |
1019 | public boolean getSupportsOnMouseDown() { | |
1020 | 0 | return false; |
1021 | } | |
1022 | ||
1023 | /** | |
1024 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnMouseDownScript() | |
1025 | */ | |
1026 | public String getOnMouseDownScript() { | |
1027 | 0 | return onMouseDownScript; |
1028 | } | |
1029 | ||
1030 | /** | |
1031 | * Setter for the components onMouseDown script | |
1032 | * | |
1033 | * @param onMouseDownScript | |
1034 | */ | |
1035 | public void setOnMouseDownScript(String onMouseDownScript) { | |
1036 | 0 | this.onMouseDownScript = onMouseDownScript; |
1037 | 0 | } |
1038 | ||
1039 | /** | |
1040 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getSupportsOnMouseMove() | |
1041 | */ | |
1042 | public boolean getSupportsOnMouseMove() { | |
1043 | 0 | return false; |
1044 | } | |
1045 | ||
1046 | /** | |
1047 | * @see org.kuali.rice.kns.uif.core.ScriptEventSupport#getOnMouseMoveScript() | |
1048 | */ | |
1049 | public String getOnMouseMoveScript() { | |
1050 | 0 | return onMouseMoveScript; |
1051 | } | |
1052 | ||
1053 | /** | |
1054 | * Setter for the components onMouseMove script | |
1055 | * | |
1056 | * @param onMouseMoveScript | |
1057 | */ | |
1058 | public void setOnMouseMoveScript(String onMouseMoveScript) { | |
1059 | 0 | this.onMouseMoveScript = onMouseMoveScript; |
1060 | 0 | } |
1061 | ||
1062 | /** | |
1063 | * @see org.kuali.rice.kns.uif.widget.Widget#getWidgetOptions() | |
1064 | */ | |
1065 | public Map<String, String> getComponentOptions() { | |
1066 | 0 | if (componentOptions == null) { |
1067 | 0 | componentOptions = new HashMap<String, String>(); |
1068 | } | |
1069 | 0 | return this.componentOptions; |
1070 | } | |
1071 | ||
1072 | /** | |
1073 | * @see org.kuali.rice.kns.uif.widget.Widget#setWidgetOptions(java.util.Map) | |
1074 | */ | |
1075 | public void setComponentOptions(Map<String, String> componentOptions) { | |
1076 | 0 | this.componentOptions = componentOptions; |
1077 | 0 | } |
1078 | ||
1079 | /** | |
1080 | * Builds a string from the underlying <code>Map</code> of component options | |
1081 | * that will export that options as a JavaScript Map for use in js and | |
1082 | * jQuery plugins | |
1083 | * | |
1084 | * @return String of widget options formatted as JS Map | |
1085 | */ | |
1086 | public String getComponentOptionsJSString() { | |
1087 | 0 | if (componentOptions == null) { |
1088 | 0 | componentOptions = new HashMap<String, String>(); |
1089 | } | |
1090 | 0 | StringBuffer sb = new StringBuffer(); |
1091 | ||
1092 | 0 | sb.append("{"); |
1093 | ||
1094 | 0 | for (String optionKey : componentOptions.keySet()) { |
1095 | 0 | String optionValue = componentOptions.get(optionKey); |
1096 | ||
1097 | 0 | if (sb.length() > 1) { |
1098 | 0 | sb.append(","); |
1099 | } | |
1100 | ||
1101 | 0 | sb.append(optionKey); |
1102 | 0 | sb.append(":"); |
1103 | ||
1104 | // If an option value starts with { or [, it would be a nested value | |
1105 | // and it should not use quotes around it | |
1106 | 0 | if (StringUtils.startsWith(optionValue, "{") || StringUtils.startsWith(optionValue, "[")) { |
1107 | 0 | sb.append(optionValue); |
1108 | } | |
1109 | else { | |
1110 | 0 | sb.append("\"" + optionValue + "\""); |
1111 | } | |
1112 | 0 | } |
1113 | ||
1114 | 0 | sb.append("}"); |
1115 | ||
1116 | 0 | return sb.toString(); |
1117 | } | |
1118 | ||
1119 | public String getEventCode() { | |
1120 | 0 | String eventCode = ""; |
1121 | ||
1122 | 0 | return eventCode; |
1123 | } | |
1124 | ||
1125 | } |