001: package org.gridsphere.provider.portletui.tags;
002:
003: import org.gridsphere.portlet.impl.SportletProperties;
004: import org.gridsphere.provider.portletui.beans.CalendarBean;
005:
006: import javax.servlet.jsp.JspException;
007: import javax.servlet.jsp.JspWriter;
008: import javax.servlet.jsp.PageContext;
009: import javax.portlet.RenderResponse;
010:
011: /**
012: * A <code>TextFieldTag</code> represents a text field element
013: */
014: public class CalendarTag extends BaseComponentTag {
015:
016: protected CalendarBean calendarBean = null;
017: protected int size = 0;
018: protected int maxlength = 0;
019:
020: /**
021: * Returns the (html) size of the field
022: *
023: * @return size of the field
024: */
025: public int getSize() {
026: return size;
027: }
028:
029: /**
030: * Sets the (html) size of the field
031: *
032: * @param size size of the field
033: */
034: public void setSize(int size) {
035: this .size = size;
036: }
037:
038: /**
039: * Returns the (html) max length of the field
040: *
041: * @return the max length of the field
042: */
043: public int getMaxlength() {
044: return maxlength;
045: }
046:
047: /**
048: * Sets the (html) max length of the field
049: *
050: * @param maxlength the max length of the field
051: */
052: public void setMaxlength(int maxlength) {
053: this .maxlength = maxlength;
054: }
055:
056: public int doStartTag() throws JspException {
057: if (!beanId.equals("")) {
058: calendarBean = (CalendarBean) getTagBean();
059: if (calendarBean == null) {
060: //log.debug("Creating new text field bean");
061: calendarBean = new CalendarBean();
062: if (maxlength != 0)
063: calendarBean.setMaxLength(maxlength);
064: if (size != 0)
065: calendarBean.setSize(size);
066: this .setBaseComponentBean(calendarBean);
067: } else {
068: //log.debug("Using existing text field bean");
069: if (maxlength != 0)
070: calendarBean.setMaxLength(maxlength);
071: if (size != 0)
072: calendarBean.setSize(size);
073: this .updateBaseComponentBean(calendarBean);
074: }
075: } else {
076: calendarBean = new CalendarBean();
077: if (maxlength != 0)
078: calendarBean.setMaxLength(maxlength);
079: if (size != 0)
080: calendarBean.setSize(size);
081: this .setBaseComponentBean(calendarBean);
082: }
083: RenderResponse res = (RenderResponse) pageContext.getAttribute(
084: SportletProperties.RENDER_RESPONSE,
085: PageContext.REQUEST_SCOPE);
086: calendarBean.setRenderResponse(res);
087: calendarBean.setId("cal_"
088: + pageContext
089: .findAttribute(SportletProperties.COMPONENT_ID)
090: + "_" + beanId);
091: try {
092: JspWriter out = pageContext.getOut();
093: out.print(calendarBean.toStartString());
094: } catch (Exception e) {
095: throw new JspException(e.getMessage());
096: }
097: return SKIP_BODY;
098: }
099:
100: }
|