01: /*
02: * Created on 20 Feb 2007
03: */
04: package uk.org.ponder.rsf.renderer.html.decorators;
05:
06: import java.util.Map;
07:
08: import uk.org.ponder.rsf.components.decorators.UIDecorator;
09: import uk.org.ponder.rsf.components.decorators.UITextDimensionsDecorator;
10: import uk.org.ponder.rsf.renderer.decorator.DecoratorRenderer;
11:
12: public class HTMLTextDimensionsDecoratorRenderer implements
13: DecoratorRenderer {
14:
15: public Class getRenderedType() {
16: return UITextDimensionsDecorator.class;
17: }
18:
19: public String getContentTypes() {
20: return "HTML, HTML-FRAGMENT";
21: }
22:
23: public void modifyAttributes(UIDecorator decoratoro,
24: String tagname, Map tomodify) {
25: UITextDimensionsDecorator decorator = (UITextDimensionsDecorator) decoratoro;
26: if (tagname.equals("textarea")) {
27: if (decorator.columns != UITextDimensionsDecorator.UNSET_VALUE) {
28: tomodify.put("cols", Integer
29: .toString(decorator.columns));
30: }
31: if (decorator.rows != UITextDimensionsDecorator.UNSET_VALUE) {
32: tomodify.put("rows", Integer.toString(decorator.rows));
33: }
34: } else if (tagname.equals("input")) {
35: if (decorator.columns != UITextDimensionsDecorator.UNSET_VALUE) {
36: tomodify.put("size", Integer
37: .toString(decorator.columns));
38: } else if (decorator.rows != UITextDimensionsDecorator.UNSET_VALUE) {
39: throw new IllegalArgumentException(
40: "Cannot set rows property on tag of type <input>");
41: }
42: } else {
43: throw new IllegalArgumentException(
44: "Cannot set text dimensions on HTML tag of type "
45: + tagname);
46: }
47: }
48:
49: }
|