Save This Page
Home » displaytag-1.1.1-src » org » displaytag » tags » [javadoc | source]
    1   /**
    2    * Licensed under the Artistic License; you may not use this file
    3    * except in compliance with the License.
    4    * You may obtain a copy of the License at
    5    *
    6    *      http://displaytag.sourceforge.net/license.html
    7    *
    8    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
    9    * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   10    * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   11    */
   12   package org.displaytag.tags;
   13   
   14   import org.displaytag.util.HtmlAttributeMap;
   15   import org.displaytag.util.MultipleHtmlAttribute;
   16   import org.displaytag.util.TagConstants;
   17   
   18   
   19   /**
   20    * Base tag which provides setters for all the standard html attributes.
   21    * @author Fabrizio Giustina
   22    * @version $Revision: 1081 $ ($Author: fgiust $)
   23    */
   24   public abstract class HtmlTableTag extends TemplateTag
   25   {
   26   
   27       /**
   28        * Map containing all the standard html attributes.
   29        */
   30       private HtmlAttributeMap attributeMap = new HtmlAttributeMap();
   31   
   32       /**
   33        * setter for the "cellspacing" html attribute.
   34        * @param value attribute value
   35        */
   36       public void setCellspacing(String value)
   37       {
   38           this.attributeMap.put(TagConstants.ATTRIBUTE_CELLSPACING, value);
   39       }
   40   
   41       /**
   42        * setter for the "cellpadding" html attribute.
   43        * @param value attribute value
   44        */
   45       public void setCellpadding(String value)
   46       {
   47           this.attributeMap.put(TagConstants.ATTRIBUTE_CELLPADDING, value);
   48       }
   49   
   50       /**
   51        * setter for the "frame" html attribute.
   52        * @param value attribute value
   53        */
   54       public void setFrame(String value)
   55       {
   56           this.attributeMap.put(TagConstants.ATTRIBUTE_FRAME, value);
   57       }
   58   
   59       /**
   60        * setter for the "rules" html attribute.
   61        * @param value attribute value
   62        */
   63       public void setRules(String value)
   64       {
   65           this.attributeMap.put(TagConstants.ATTRIBUTE_RULES, value);
   66       }
   67   
   68       /**
   69        * setter for the "style" html attribute.
   70        * @param value attribute value
   71        */
   72       public void setStyle(String value)
   73       {
   74           this.attributeMap.put(TagConstants.ATTRIBUTE_STYLE, value);
   75       }
   76   
   77       /**
   78        * setter for the "summary" html attribute.
   79        * @param value attribute value
   80        */
   81       public void setSummary(String value)
   82       {
   83           this.attributeMap.put(TagConstants.ATTRIBUTE_SUMMARY, value);
   84       }
   85   
   86       /**
   87        * setter for the "class" html attribute.
   88        * @param value attribute value
   89        */
   90       public void setClass(String value)
   91       {
   92           this.attributeMap.put(TagConstants.ATTRIBUTE_CLASS, new MultipleHtmlAttribute(value));
   93       }
   94   
   95       /**
   96        * setter for the "id" html attribute. Don't use setId() to avoid overriding original TagSupport method.
   97        * @param value attribute value
   98        */
   99       public void setHtmlId(String value)
  100       {
  101           this.attributeMap.put(TagConstants.ATTRIBUTE_ID, value);
  102       }
  103   
  104       /**
  105        * Adds a css class to the class attribute (html class suports multiple values).
  106        * @param value attribute value
  107        */
  108       public void addClass(String value)
  109       {
  110           Object classAttributes = this.attributeMap.get(TagConstants.ATTRIBUTE_CLASS);
  111   
  112           if (classAttributes == null)
  113           {
  114               this.attributeMap.put(TagConstants.ATTRIBUTE_CLASS, new MultipleHtmlAttribute(value));
  115           }
  116           else
  117           {
  118               ((MultipleHtmlAttribute) classAttributes).addAttributeValue(value);
  119           }
  120       }
  121   
  122       /**
  123        * @see javax.servlet.jsp.tagext.Tag#release()
  124        */
  125       public void release()
  126       {
  127           this.attributeMap.clear();
  128           super.release();
  129       }
  130   
  131       /**
  132        * Return a map of html attributes. Should be used for extensions only, html attributes are normally printed out in
  133        * the <code>getOpenTag()</code> method.
  134        * @return map of html attributes
  135        */
  136       public HtmlAttributeMap getAttributeMap()
  137       {
  138           return this.attributeMap;
  139       }
  140   
  141   }

Save This Page
Home » displaytag-1.1.1-src » org » displaytag » tags » [javadoc | source]