PageRenderTime 19ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 11ms app.codeStats 0ms

/src/main/java/com/googlecode/struts2yuiplugin/components/YUIBean.java

http://struts2yuiplugin.googlecode.com/
Java | 152 lines | 115 code | 28 blank | 9 comment | 5 complexity | 34a7c33a5d9f3a7ccf57371d706c3507 MD5 | raw file
  1package com.googlecode.struts2yuiplugin.components;
  2
  3import com.googlecode.struts2yuiplugin.tools.YUITools;
  4import com.opensymphony.xwork2.util.ValueStack;
  5import org.apache.struts2.components.UIBean;
  6import org.apache.struts2.views.annotations.StrutsTagAttribute;
  7
  8import javax.servlet.http.HttpServletRequest;
  9import javax.servlet.http.HttpServletResponse;
 10
 11/**
 12 * YUIBean is a standard base-class for the YUI components.
 13 * The main purpose is to remove the attributes inherited from UIBean and to support the 'noscript' feature
 14 *
 15 */
 16public abstract class YUIBean extends UIBean {
 17
 18    private String widget;
 19    private String noscript;
 20
 21    protected YUIBean(ValueStack valueStack, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
 22        super(valueStack, httpServletRequest, httpServletResponse);
 23    }
 24
 25    @Override
 26    public void evaluateParams() {
 27        super.evaluateParams();
 28
 29        populateWidgetName();
 30
 31        if (noscript != null) {
 32            this.addParameter("noscript", findValue(noscript, Boolean.class));
 33        } 
 34
 35        this.addParameter("defaultHandler", true);
 36    }
 37
 38    /**
 39     * Generate the javascript name for this widget if not explictly specified.
 40     * The name is generated from the escaped Id generated by UIBean
 41     */
 42    private void populateWidgetName() {
 43        String widgetName;
 44        if (widget != null) {
 45            widgetName = widget;
 46        } else {
 47            widgetName = YUITools.sanitizeForJavascript(getId()+"Widget");
 48        }
 49        addParameter("widget", widgetName);
 50    }
 51
 52
 53    @Override
 54    @StrutsTagAttribute(description = "HTML id attribute", rtexprvalue = true)
 55    public void setId(String id) {
 56        super.setId(id);
 57    }
 58
 59    @StrutsTagAttribute(description = "A unique javascript name to assign to this widget.  Use to specify a namespace.", required = false)
 60    public void setWidget(String widget) {
 61        this.widget = widget;
 62    }
 63
 64    @StrutsTagAttribute(description = "If true the tag will not include any associated javascript", required = false, defaultValue = "false")
 65    public void setNoscript(String noscript) {
 66        this.noscript = noscript;
 67    }
 68
 69    @Override
 70    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
 71    public void setOnclick(String string) {
 72        super.setOnclick(string);
 73    }
 74
 75    @Override
 76    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
 77    public void setOndblclick(String string) {
 78        super.setOndblclick(string);
 79    }
 80
 81    @Override
 82    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
 83    public void setOnmousedown(String string) {
 84        super.setOnmousedown(string);
 85    }
 86
 87    @Override
 88    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
 89    public void setOnmouseup(String string) {
 90        super.setOnmouseup(string);
 91    }
 92
 93    @Override
 94    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
 95    public void setOnmouseover(String string) {
 96        super.setOnmouseover(string);
 97    }
 98
 99    @Override
100    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
101    public void setOnmousemove(String string) {
102        super.setOnmousemove(string);
103    }
104
105    @Override
106    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
107    public void setOnmouseout(String string) {
108        super.setOnmouseout(string);
109    }
110
111    @Override
112    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
113    public void setOnfocus(String string) {
114        super.setOnfocus(string);
115    }
116
117    @Override
118    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
119    public void setOnblur(String string) {
120        super.setOnblur(string);
121    }
122
123    @Override
124    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
125    public void setOnkeypress(String string) {
126        super.setOnkeypress(string);
127    }
128
129    @Override
130    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
131    public void setOnkeydown(String string) {
132        super.setOnkeydown(string);
133    }
134
135    @Override
136    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
137    public void setOnkeyup(String string) {
138        super.setOnkeyup(string);
139    }
140
141    @Override
142    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
143    public void setOnselect(String string) {
144        super.setOnselect(string);
145    }
146
147    @Override
148    @StrutsTagAttribute(description = "Not supported - use the YUI event utility")
149    public void setOnchange(String string) {
150        super.setOnchange(string);
151    }
152}