01: /*
02: * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
03: * @version $Id: ActionSubmitBean.java 6428 2008-03-05 11:46:37Z wehrens $
04: */
05:
06: package org.gridsphere.provider.portletui.beans;
07:
08: /**
09: * An <code>ActionSubmitBean</code> is a visual bean that represents an HTML button and
10: * has an associated <code>DefaultPortletAction</code>
11: */
12: public class ActionSubmitBean extends ActionBean implements TagBean {
13:
14: public static final String SUBMIT_STYLE = "portlet-form-button";
15: public static final String NAME = "as";
16:
17: protected String imageSrc = null;
18:
19: /**
20: * Constructs a default action submit bean
21: */
22: public ActionSubmitBean() {
23: super (NAME);
24: this .cssClass = SUBMIT_STYLE;
25: }
26:
27: /**
28: * Constructs an action submit bean from a supplied portlet request and bean identifier
29: *
30: * @param beanId the bean identifier
31: */
32: public ActionSubmitBean(String beanId) {
33: super (NAME);
34: this .cssClass = SUBMIT_STYLE;
35: this .beanId = beanId;
36: }
37:
38: public String getImageSrc() {
39: return imageSrc;
40: }
41:
42: public void setImageSrc(String imageSrc) {
43: this .imageSrc = imageSrc;
44: }
45:
46: public String toStartString() {
47: return "";
48: }
49:
50: public String toEndString() {
51: String sname = (name == null) ? "" : name;
52: StringBuffer sb = new StringBuffer();
53:
54: String inputType = "submit";
55: if (useAjax)
56: inputType = "button";
57: if (imageSrc != null)
58: inputType = "image";
59: sb.append("<input ");
60: if (id != null)
61: sb.append("id=\"").append(id).append("\" ");
62: sb.append(getFormattedCss()).append("type=\"")
63: .append(inputType).append("\" ")
64: .append(checkDisabled());
65: if (imageSrc != null)
66: sb.append("src=\"").append(imageSrc).append("\" ");
67: if (action != null)
68: sname = action;
69: if (anchor != null)
70: sname += "#" + anchor;
71: if (onClick != null) {
72: // 'onClick' replaced by 'onclick' for XHTML 1.0 Strict compliance
73: sb.append("onclick=\"").append(onClick).append("\" ");
74: }
75: sb.append("name=\"").append(sname).append("\" value=\"")
76: .append(value).append("\"/>");
77: return sb.toString();
78: }
79:
80: }
|