01: package org.gridsphere.provider.portletui.beans;
02:
03: import org.gridsphere.portlet.service.spi.PortletServiceFactory;
04: import org.gridsphere.services.core.portal.PortalConfigService;
05:
06: import javax.portlet.RenderResponse;
07:
08: /**
09: * The <code>TextBean</code> represents text to be displayed
10: */
11: public class CalendarBean extends InputBean implements TagBean {
12:
13: public RenderResponse renderResponse;
14:
15: /**
16: * Constructs a default text bean
17: */
18: public CalendarBean() {
19: super (TagBean.CALENDAR_NAME);
20: this .inputtype = "text";
21: }
22:
23: /**
24: * Constructs a text bean using a supplied bean identifier
25: *
26: * @param beanId the bean identifier
27: */
28: public CalendarBean(String beanId) {
29: this ();
30: this .beanId = beanId;
31: }
32:
33: public RenderResponse getRenderResponse() {
34: return renderResponse;
35: }
36:
37: public void setRenderResponse(RenderResponse renderResponse) {
38: this .renderResponse = renderResponse;
39: }
40:
41: public String toStartString() {
42:
43: PortalConfigService configService = (PortalConfigService) PortletServiceFactory
44: .createPortletService(PortalConfigService.class, true);
45: // deal with ROOT context case
46: String contextPath = configService
47: .getProperty("gridsphere.deploy");
48: if (!contextPath.equals(""))
49: contextPath = "/" + contextPath;
50: renderResponse.addProperty("JAVASCRIPT_SRC", contextPath
51: + "/javascript/scw.js");
52: StringBuffer sb = new StringBuffer();
53: sb.append("<input " + getFormattedCss() + " ");
54: sb.append("id=\"" + id + "\" ");
55: sb.append("type=\"text\" ");
56: String sname = createTagName(name);
57: sb.append("name=\"" + sname + "\" ");
58: if (value != null)
59: sb.append("value=\"" + value + "\" ");
60: if (size != 0)
61: sb.append("size=\"" + size + "\" ");
62: if (maxlength != 0)
63: sb.append("maxlength=\"" + maxlength + "\" ");
64: sb.append(checkReadOnly());
65: sb.append(checkDisabled());
66: sb.append("/>");
67: sb
68: .append("<button class=\"cal\" type=\"submit\" title=\"Calendar\" alt=\"Calendar\" onclick=\"scwShow(document.getElementById('"
69: + id + "'),this);\">Calendar</button>");
70: return sb.toString();
71: }
72:
73: }
|