Save This Page
Home » displaytag-1.1.1-src » org » displaytag » tags » el » [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.el;
   13   
   14   import javax.servlet.jsp.JspException;
   15   
   16   
   17   /**
   18    * Adds EL support to displaytag's TableTag.
   19    * @author Tim McCune
   20    * @author Fabrizio Giustina
   21    * @version $Revision: 1081 $ ($Author: fgiust $)
   22    */
   23   public class ELTableTag extends org.displaytag.tags.TableTag
   24   {
   25   
   26       /**
   27        * D1597A17A6.
   28        */
   29       private static final long serialVersionUID = 899149338534L;
   30   
   31       /**
   32        * Expression for the "class" tag attribute.
   33        */
   34       private String classExpr;
   35   
   36       /**
   37        * Expression for the "cellpadding" tag attribute.
   38        */
   39       private String cellpaddingExpr;
   40   
   41       /**
   42        * Expression for the "cellspacing" tag attribute.
   43        */
   44       private String cellspacingExpr;
   45   
   46       /**
   47        * Expression for the "decorator" tag attribute.
   48        */
   49       private String decoratorExpr;
   50   
   51       /**
   52        * Expression for the "defaultsort" tag attribute.
   53        */
   54       private String defaultsortExpr;
   55   
   56       /**
   57        * Expression for the "defaultorder" tag attribute.
   58        */
   59       private String defaultorderExpr;
   60   
   61       /**
   62        * Expression for the "export" tag attribute.
   63        */
   64       private String exportExpr;
   65   
   66       /**
   67        * Expression for the "frame" tag attribute.
   68        */
   69       private String frameExpr;
   70   
   71       /**
   72        * Expression for the "length" tag attribute.
   73        */
   74       private String lengthExpr;
   75   
   76       /**
   77        * Expression for the "name" tag attribute.
   78        */
   79       private String nameExpr;
   80   
   81       /**
   82        * Expression for the "offset" tag attribute.
   83        */
   84       private String offsetExpr;
   85   
   86       /**
   87        * Expression for the "pagesize" tag attribute.
   88        */
   89       private String pagesizeExpr;
   90   
   91       /**
   92        * Expression for the "partialList" tag attribute.
   93        */
   94       private String partialListExpr;
   95   
   96       /**
   97        * Expression for the "requestURI" tag attribute.
   98        */
   99       private String requestURIExpr;
  100   
  101       /**
  102        * Expression for the "requestURIcontext" tag attribute.
  103        */
  104       private String requestURIcontextExpr;
  105   
  106       /**
  107        * Expression for the "rules" tag attribute.
  108        */
  109       private String rulesExpr;
  110   
  111       /**
  112        * Expression for the "size" tag attribute
  113        */
  114       private String sizeExpr;
  115   
  116       /**
  117        * Expression for the "sort" tag attribute.
  118        */
  119       private String sortExpr;
  120   
  121       /**
  122        * Expression for the "style" tag attribute.
  123        */
  124       private String styleExpr;
  125   
  126       /**
  127        * Expression for the "summary" tag attribute.
  128        */
  129       private String summaryExpr;
  130   
  131       /**
  132        * Expression for the "excludedParams" tag attribute.
  133        */
  134       private String excludedParamsExpr;
  135   
  136       /**
  137        * Expression for the "id" tag attribute.
  138        */
  139       private String idExpr;
  140   
  141       /**
  142        * Expression for the "htmlId" tag attribute.
  143        */
  144       private String htmlIdExpr;
  145   
  146       /**
  147        * @see org.displaytag.tags.TableTag#setUid(java.lang.String)
  148        */
  149       public void setUid(String value)
  150       {
  151           idExpr = value;
  152       }
  153   
  154       /**
  155        * @see org.displaytag.tags.TableTag#setCellpadding(java.lang.String)
  156        * @param value EL expression for attribute value
  157        */
  158       public void setCellpadding(String value)
  159       {
  160           cellpaddingExpr = value;
  161       }
  162   
  163       /**
  164        * @see org.displaytag.tags.TableTag#setStyle(java.lang.String)
  165        * @param value EL expression for attribute value
  166        */
  167       public void setStyle(String value)
  168       {
  169           styleExpr = value;
  170       }
  171   
  172       /**
  173        * @see org.displaytag.tags.TableTag#setSummary(java.lang.String)
  174        * @param value EL expression for attribute value
  175        */
  176       public void setSummary(String value)
  177       {
  178           summaryExpr = value;
  179       }
  180   
  181       /**
  182        * @see org.displaytag.tags.TableTag#setCellspacing(java.lang.String)
  183        * @param value EL expression for attribute value
  184        */
  185       public void setCellspacing(String value)
  186       {
  187           cellspacingExpr = value;
  188       }
  189   
  190       /**
  191        * @see org.displaytag.tags.TableTag#setClass(java.lang.String)
  192        * @param value EL expression for attribute value
  193        */
  194       public void setClass(String value)
  195       {
  196           classExpr = value;
  197       }
  198   
  199       /**
  200        * @see org.displaytag.tags.TableTag#setDecorator(java.lang.String)
  201        * @param value EL expression for attribute value
  202        */
  203       public void setDecorator(String value)
  204       {
  205           decoratorExpr = value;
  206       }
  207   
  208       /**
  209        * @see org.displaytag.tags.TableTag#setDefaultsort(int)
  210        * @param value EL expression for attribute value
  211        */
  212       public void setDefaultsort(String value)
  213       {
  214           defaultsortExpr = value;
  215       }
  216   
  217       /**
  218        * @see org.displaytag.tags.TableTag#setDefaultorder(java.lang.String)
  219        * @param value EL expression for attribute value
  220        */
  221       public void setDefaultorder(String value)
  222       {
  223           defaultorderExpr = value;
  224       }
  225   
  226       /**
  227        * @see org.displaytag.tags.TableTag#setExport(boolean)
  228        * @param value EL expression for attribute value
  229        */
  230       public void setExport(String value)
  231       {
  232           exportExpr = value;
  233       }
  234   
  235       /**
  236        * @see org.displaytag.tags.TableTag#setFrame(java.lang.String)
  237        * @param value EL expression for attribute value
  238        */
  239       public void setFrame(String value)
  240       {
  241           frameExpr = value;
  242       }
  243   
  244       /**
  245        * @see org.displaytag.tags.TableTag#setLength(int)
  246        * @param value EL expression for attribute value
  247        */
  248       public void setLength(String value)
  249       {
  250           lengthExpr = value;
  251       }
  252   
  253       /**
  254        * @see org.displaytag.tags.TableTag#setName(java.lang.Object)
  255        * @param value EL expression for attribute value
  256        */
  257       public void setName(String value)
  258       {
  259           nameExpr = value;
  260       }
  261   
  262       /**
  263        * @see org.displaytag.tags.TableTag#setOffset(int)
  264        * @param value EL expression for attribute value
  265        */
  266       public void setOffset(String value)
  267       {
  268           offsetExpr = value;
  269       }
  270   
  271       /**
  272        * @see org.displaytag.tags.TableTag#setPagesize(int)
  273        * @param value EL expression for attribute value
  274        */
  275       public void setPagesize(String value)
  276       {
  277           pagesizeExpr = value;
  278       }
  279   
  280       /**
  281        * @see org.displaytag.tags.TableTag#setRequestURI(java.lang.String)
  282        * @param value EL expression for attribute value
  283        */
  284       public void setRequestURI(String value)
  285       {
  286           requestURIExpr = value;
  287       }
  288   
  289       /**
  290        * @see org.displaytag.tags.TableTag#setRequestURIcontext(boolean)
  291        * @param value EL expression for attribute value
  292        */
  293       public void setRequestURIcontext(String value)
  294       {
  295           requestURIcontextExpr = value;
  296       }
  297   
  298       /**
  299        * @see org.displaytag.tags.TableTag#setRules(java.lang.String)
  300        * @param value EL expression for attribute value
  301        */
  302       public void setRules(String value)
  303       {
  304           rulesExpr = value;
  305       }
  306   
  307       /**
  308        * @param value EL expression for attribute value
  309        * @see org.displaytag.tags.TableTag#setSize(java.lang.String)
  310        */
  311       public void setSize(String value)
  312       {
  313           sizeExpr = value;
  314       }
  315   
  316       /**
  317        * @see org.displaytag.tags.TableTag#setSort(java.lang.String)
  318        * @param value EL expression for attribute value
  319        */
  320       public void setSort(String value)
  321       {
  322           sortExpr = value;
  323       }
  324   
  325       /**
  326        * @see org.displaytag.tags.TableTag#setExcludedParams(java.lang.String)
  327        * @param value EL expression for attribute value
  328        */
  329       public void setExcludedParams(String value)
  330       {
  331           excludedParamsExpr = value;
  332       }
  333   
  334       /**
  335        * @see org.displaytag.tags.TableTag#setHtmlId(java.lang.String)
  336        * @param value EL expression for attribute value
  337        */
  338       public void setHtmlId(String value)
  339       {
  340           htmlIdExpr = value;
  341       }
  342   
  343       /**
  344        * @see javax.servlet.jsp.tagext.Tag#doStartTag()
  345        */
  346       public int doStartTag() throws JspException
  347       {
  348           evaluateExpressions();
  349           return super.doStartTag();
  350       }
  351   
  352       /**
  353        * Evaluates EL expressions and sets values in the parent Table Tag.
  354        * @throws JspException for errors during evaluation
  355        */
  356       private void evaluateExpressions() throws JspException
  357       {
  358           ExpressionEvaluator eval = new ExpressionEvaluator(this, pageContext);
  359   
  360           if (idExpr != null)
  361           {
  362               super.setUid(eval.evalString("uid", idExpr)); //$NON-NLS-1$
  363           }
  364           if (htmlIdExpr != null)
  365           {
  366               super.setHtmlId(eval.evalString("htmlId", htmlIdExpr)); //$NON-NLS-1$
  367           }
  368           if (cellpaddingExpr != null)
  369           {
  370               super.setCellpadding(eval.evalString("cellpadding", cellpaddingExpr)); //$NON-NLS-1$
  371           }
  372           if (cellspacingExpr != null)
  373           {
  374               super.setCellspacing(eval.evalString("cellspacing", cellspacingExpr)); //$NON-NLS-1$
  375           }
  376           if (classExpr != null)
  377           {
  378               super.setClass(eval.evalString("class", classExpr)); //$NON-NLS-1$
  379           }
  380           if (decoratorExpr != null)
  381           {
  382               super.setDecorator(eval.evalString("decorator", decoratorExpr)); //$NON-NLS-1$
  383           }
  384           if (defaultorderExpr != null)
  385           {
  386               super.setDefaultorder(eval.evalString("defaultorder", defaultorderExpr)); //$NON-NLS-1$
  387           }
  388           if (excludedParamsExpr != null)
  389           {
  390               super.setExcludedParams(eval.evalString("excludedParams", excludedParamsExpr)); //$NON-NLS-1$
  391           }
  392           if (defaultsortExpr != null)
  393           {
  394               super.setDefaultsort(eval.evalInt("defaultsort", defaultsortExpr)); //$NON-NLS-1$
  395           }
  396           if (exportExpr != null)
  397           {
  398               super.setExport(eval.evalBoolean("export", exportExpr)); //$NON-NLS-1$
  399           }
  400           if (frameExpr != null)
  401           {
  402               super.setFrame(eval.evalString("frame", frameExpr)); //$NON-NLS-1$
  403           }
  404           if (lengthExpr != null)
  405           {
  406               super.setLength(eval.evalInt("length", lengthExpr)); //$NON-NLS-1$
  407           }
  408           if (nameExpr != null)
  409           {
  410               Object source = eval.eval("name", nameExpr, Object.class); //$NON-NLS-1$
  411   
  412               // be more user-friendly: accept both EL and legacy expressions
  413               if (source instanceof String)
  414               {
  415                   super.setNameString((String) source);
  416               }
  417               else
  418               {
  419                   // evaluate name only once, so assign it to "list"
  420                   super.list = source;
  421               }
  422           }
  423           if (offsetExpr != null)
  424           {
  425               super.setOffset(eval.evalInt("offset", offsetExpr)); //$NON-NLS-1$
  426           }
  427           if (pagesizeExpr != null)
  428           {
  429               super.setPagesize(eval.evalInt("pagesize", pagesizeExpr)); //$NON-NLS-1$
  430           }
  431           if (partialListExpr != null)
  432           {
  433               super.setPartialList(eval.evalBoolean("partialList", partialListExpr)); //$NON-NLS-1$
  434           }
  435           if (requestURIExpr != null)
  436           {
  437               super.setRequestURI(eval.evalString("requestURI", requestURIExpr)); //$NON-NLS-1$
  438           }
  439           if (requestURIcontextExpr != null)
  440           {
  441               super.setRequestURIcontext(eval.evalBoolean("requestURIcontext", requestURIcontextExpr)); //$NON-NLS-1$
  442           }
  443           if (rulesExpr != null)
  444           {
  445               super.setRules(eval.evalString("rules", rulesExpr)); //$NON-NLS-1$
  446           }
  447           if (sizeExpr != null)
  448           {
  449               Object source = eval.eval("size", sizeExpr, Object.class); //$NON-NLS-1$
  450   
  451               // be more user-friendly: accept both EL and legacy expressions
  452               if (source instanceof String)
  453               {
  454                   super.setSizeObjectName((String) source);
  455               }
  456               else
  457               {
  458                   // evaluate size only once, so assign it to the "size" object
  459                   super.setSize(source);
  460               }
  461           }
  462           if (sortExpr != null)
  463           {
  464               super.setSort(eval.evalString("sort", sortExpr)); //$NON-NLS-1$
  465           }
  466           if (styleExpr != null)
  467           {
  468               super.setStyle(eval.evalString("style", styleExpr)); //$NON-NLS-1$
  469           }
  470           if (summaryExpr != null)
  471           {
  472               super.setSummary(eval.evalString("summary", summaryExpr)); //$NON-NLS-1$
  473           }
  474       }
  475   
  476       /**
  477        * @see javax.servlet.jsp.tagext.Tag#release()
  478        */
  479       public void release()
  480       {
  481           super.release();
  482           this.cellpaddingExpr = null;
  483           this.cellspacingExpr = null;
  484           this.classExpr = null;
  485           this.decoratorExpr = null;
  486           this.defaultorderExpr = null;
  487           this.defaultsortExpr = null;
  488           this.exportExpr = null;
  489           this.frameExpr = null;
  490           this.lengthExpr = null;
  491           this.nameExpr = null;
  492           this.offsetExpr = null;
  493           this.pagesizeExpr = null;
  494           this.partialListExpr = null;
  495           this.requestURIExpr = null;
  496           this.requestURIcontextExpr = null;
  497           this.rulesExpr = null;
  498           this.sizeExpr = null;
  499           this.sortExpr = null;
  500           this.styleExpr = null;
  501           this.summaryExpr = null;
  502           this.excludedParamsExpr = null;
  503           this.idExpr = null;
  504           this.htmlIdExpr = null;
  505       }
  506   
  507   }

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