001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * Initial developer(s): Michel-Ange ANTON
022: * --------------------------------------------------------------------------
023: * $Id: GridRowTag.java 2637 2003-06-20 17:15:42Z antonma $
024: * --------------------------------------------------------------------------
025: */
026:
027: package org.objectweb.jonas.webapp.taglib;
028:
029: import javax.servlet.jsp.tagext.Tag;
030:
031: public class GridRowTag extends GridTableBaseTag {
032:
033: // ----------------------------------------------------- Properties
034:
035: private boolean changeStyle = false;
036:
037: public boolean isChangeStyle() {
038: return changeStyle;
039: }
040:
041: public void setChangeStyle(boolean changeStyle) {
042: this .changeStyle = changeStyle;
043: }
044:
045: // ----------------------------------------------------- Public Methods
046:
047: /**
048: * Release resources after Tag processing has finished.
049: */
050: public void release() {
051: super .release();
052: changeStyle = false;
053: }
054:
055: // ----------------------------------------------------- Protected Methods
056:
057: /**
058: * Return the HTML element.
059: */
060: protected String getHtmlElement() {
061: return "tr";
062: }
063:
064: /**
065: * Duplicate of <code>BaseHandlerTag.prepareStyles()" method.
066: * Add the alternate class (odd or even) with .
067: *
068: * @return The prepared String for inclusion in the HTML tag.
069: */
070: protected String prepareStyles() {
071: StringBuffer styles = new StringBuffer();
072: if (getStyle() != null) {
073: styles.append(" style=\"");
074: styles.append(getStyle());
075: styles.append("\"");
076: }
077:
078: // Get the row class from the GridTag parent
079: String sClass = getStyleClass();
080: if (sClass == null) {
081: sClass = getRowClass();
082: }
083: // Render class
084: if (sClass != null) {
085: styles.append(" class=\"");
086: styles.append(sClass);
087: styles.append("\"");
088: }
089:
090: if (getStyleId() != null) {
091: styles.append(" id=\"");
092: styles.append(getStyleId());
093: styles.append("\"");
094: }
095: if (getTitle() != null) {
096: styles.append(" title=\"");
097: styles.append(getTitle());
098: styles.append("\"");
099: }
100: return styles.toString();
101: }
102:
103: /**
104: * Determine the Row Class from the GridTag.
105: */
106: protected String getRowClass() {
107: // Determine if embedded in an GridTag
108: Tag tag = findAncestorWithClass(this , GridTag.class);
109: if (tag == null) {
110: return null;
111: }
112: // Determine the current row number
113: GridTag oTag = (GridTag) tag;
114: return oTag.getRowStyle(changeStyle);
115: }
116:
117: }
|