01: package com.opensymphony.webwork.components;
02:
03: import com.opensymphony.xwork.util.OgnlValueStack;
04:
05: import javax.servlet.http.HttpServletRequest;
06: import javax.servlet.http.HttpServletResponse;
07:
08: /**
09: * <!-- START SNIPPET: javadoc -->
10: * Render an HTML input field of type text</p>
11: * <!-- END SNIPPET: javadoc -->
12: *
13: * <p/> <b>Examples</b>
14: * <p/>
15: * <!-- START SNIPPET: exdescription -->
16: * In this example, a text control is rendered. The label is retrieved from a ResourceBundle by calling
17: * ActionSupport's getText() method.<p/>
18: * <!-- END SNIPPET: exdescription -->
19: * <pre>
20: * <!-- START SNIPPET: example -->
21: * <ww:textfield label="%{text('user_name')}" name="user" />
22: * <!-- END SNIPPET: example -->
23: * </pre>
24: *
25: * @author Patrick Lightbody
26: * @author Rene Gielen
27: * @version $Revision: 2468 $
28: * @since 2.2
29: *
30: * @ww.tag name="textfield" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.ui.TextFieldTag"
31: * description="Render an HTML input field of type text"
32: */
33: public class TextField extends UIBean {
34: /**
35: * The name of the default template for the TextFieldTag
36: */
37: final public static String TEMPLATE = "text";
38:
39: protected String maxlength;
40: protected String readonly;
41: protected String size;
42:
43: public TextField(OgnlValueStack stack, HttpServletRequest request,
44: HttpServletResponse response) {
45: super (stack, request, response);
46: }
47:
48: protected String getDefaultTemplate() {
49: return TEMPLATE;
50: }
51:
52: protected void evaluateExtraParams() {
53: super .evaluateExtraParams();
54:
55: if (size != null) {
56: addParameter("size", findString(size));
57: }
58:
59: if (maxlength != null) {
60: addParameter("maxlength", findString(maxlength));
61: }
62:
63: if (readonly != null) {
64: addParameter("readonly", findValue(readonly, Boolean.class));
65: }
66: }
67:
68: /**
69: * HTML maxlength attribute
70: * @ww.tagattribute required="false" type="Integer"
71: */
72: public void setMaxlength(String maxlength) {
73: this .maxlength = maxlength;
74: }
75:
76: /**
77: * Deprecated. Use maxlength instead.
78: * @ww.tagattribute required="false"
79: */
80: public void setMaxLength(String maxlength) {
81: this .maxlength = maxlength;
82: }
83:
84: /**
85: * Whether the input is readonly
86: * @ww.tagattribute required="false" type="Boolean" default="false"
87: */
88: public void setReadonly(String readonly) {
89: this .readonly = readonly;
90: }
91:
92: /**
93: * HTML size attribute
94: * @ww.tagattribute required="false" type="Integer"
95: */
96: public void setSize(String size) {
97: this.size = size;
98: }
99: }
|