001: /**
002: * Copyright 2006 Webmedia Group Ltd.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: **/package org.araneaframework.jsp.tag.uilib.form.element.text;
016:
017: import java.io.Writer;
018: import javax.servlet.jsp.JspException;
019: import org.apache.commons.lang.StringUtils;
020: import org.araneaframework.jsp.tag.basic.AttributedTagInterface;
021: import org.araneaframework.jsp.tag.uilib.form.BaseFormElementHtmlTag;
022: import org.araneaframework.jsp.util.JspUtil;
023: import org.araneaframework.uilib.form.control.StringArrayRequestControl;
024:
025: /**
026: * Standard text input form element tag.
027: *
028: * @author Oleg Mürk
029: *
030: * @jsp.tag
031: * name = "textarea"
032: * body-content = "JSP"
033: * description = "Form text input field (textarea), represents UiLib 'TextareaControl'."
034: */
035: public class FormTextareaHtmlTag extends BaseFormElementHtmlTag {
036: protected Long cols;
037: protected Long rows;
038:
039: {
040: baseStyleClass = "aranea-textarea";
041: }
042:
043: protected int doStartTag(Writer out) throws Exception {
044: super .doStartTag(out);
045: addContextEntry(AttributedTagInterface.HTML_ELEMENT_KEY, null);
046: return EVAL_BODY_INCLUDE;
047: }
048:
049: protected int doEndTag(Writer out) throws Exception {
050: assertControlType("TextareaControl");
051:
052: String name = this .getFullFieldId();
053: StringArrayRequestControl.ViewModel viewModel = ((StringArrayRequestControl.ViewModel) controlViewModel);
054:
055: JspUtil.writeOpenStartTag(out, "textarea");
056: JspUtil.writeAttribute(out, "id", name);
057: JspUtil.writeAttribute(out, "name", name);
058: JspUtil.writeAttribute(out, "class", getStyleClass());
059: JspUtil.writeAttribute(out, "style", getStyle());
060:
061: JspUtil.writeAttribute(out, "cols", cols);
062: JspUtil.writeAttribute(out, "rows", rows);
063: JspUtil.writeAttribute(out, "tabindex", tabindex);
064: if (viewModel.isDisabled())
065: JspUtil.writeAttribute(out, "disabled", "true");
066: JspUtil.writeAttributes(out, attributes);
067: JspUtil.writeCloseStartTag(out);
068: JspUtil.writeEscaped(out, viewModel.getSimpleValue());
069: JspUtil.writeEndTag_SS(out, "textarea");
070: if (!StringUtils.isBlank(accessKey))
071: JspUtil.writeAttribute(out, "accesskey", accessKey);
072:
073: super .doEndTag(out);
074: return EVAL_PAGE;
075: }
076:
077: /* ***********************************************************************************
078: * Tag attributes
079: * ***********************************************************************************/
080:
081: /**
082: * @jsp.attribute
083: * type = "java.lang.String"
084: * required = "false"
085: * description = "Number of visible columns."
086: */
087: public void setCols(String size) throws JspException {
088: this .cols = (Long) evaluate("cols", size, Long.class);
089: }
090:
091: /**
092: * @jsp.attribute
093: * type = "java.lang.String"
094: * required = "false"
095: * description = "Number of visible rows."
096: */
097: public void setRows(String size) throws JspException {
098: this .rows = (Long) evaluate("rows", size, Long.class);
099: }
100: }
|