01: /*
02: * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
03: * @version $Id: FileInputTag.java 6385 2007-10-25 14:02:26Z wehrens $
04: */
05: package org.gridsphere.provider.portletui.tags;
06:
07: import org.gridsphere.provider.portletui.beans.FileInputBean;
08:
09: import javax.servlet.jsp.JspException;
10: import javax.servlet.jsp.JspWriter;
11:
12: /**
13: * A <code>FileInputTag</code> represnts a file input element to be used for uploading files
14: */
15: public class FileInputTag extends BaseComponentTag {
16:
17: protected FileInputBean fileInputBean = null;
18: protected int size = 0;
19: protected int maxlength = 0;
20:
21: /**
22: * Returns the (html) size of the field
23: *
24: * @return size of the field
25: */
26: public int getSize() {
27: return size;
28: }
29:
30: /**
31: * Sets the (html) size of the field
32: *
33: * @param size size of the field
34: */
35: public void setSize(int size) {
36: this .size = size;
37: }
38:
39: /**
40: * Returns the (html) maxlength of the field
41: *
42: * @return the max length of the field
43: */
44: public int getMaxlength() {
45: return maxlength;
46: }
47:
48: /**
49: * Sets the (html) max length of the field
50: *
51: * @param maxlength the max length of the field
52: */
53: public void setMaxlength(int maxlength) {
54: this .maxlength = maxlength;
55: }
56:
57: public int doStartTag() throws JspException {
58: if (!beanId.equals("")) {
59: fileInputBean = (FileInputBean) getTagBean();
60: if (fileInputBean == null) {
61: fileInputBean = new FileInputBean();
62: fileInputBean.setBeanId(beanId);
63: this .setBaseComponentBean(fileInputBean);
64: } else {
65: this .updateBaseComponentBean(fileInputBean);
66: }
67: } else {
68: fileInputBean = new FileInputBean();
69: this .setBaseComponentBean(fileInputBean);
70: if (maxlength != 0)
71: fileInputBean.setMaxLength(maxlength);
72: if (size != 0)
73: fileInputBean.setSize(size);
74: }
75:
76: //debug();
77:
78: try {
79: JspWriter out = pageContext.getOut();
80: out.print(fileInputBean.toStartString());
81: } catch (Exception e) {
82: throw new JspException(e.getMessage());
83: }
84:
85: return SKIP_BODY;
86: }
87:
88: }
|