View Javadoc

1   /*
2    * $Id: ELPutListTag.java 376781 2006-02-10 18:09:48Z husted $
3    *
4    * Copyright 1999-2004 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.strutsel.taglib.tiles;
19  
20  import org.apache.struts.tiles.taglib.PutListTag;
21  import org.apache.strutsel.taglib.utils.EvalHelper;
22  
23  import javax.servlet.jsp.JspException;
24  
25  /***
26   * PutList tag implementation. <p> This class is a subclass of the class
27   * <code>org.apache.struts.taglib.tiles.PutListTag</code> which provides most
28   * of the described functionality.  This subclass allows all attribute values
29   * to be specified as expressions utilizing the JavaServer Pages Standard
30   * Library expression language.
31   *
32   * @version $Rev: 376781 $
33   */
34  public class ELPutListTag extends PutListTag {
35      /***
36       * Instance variable mapped to "name" tag attribute. (Mapping set in
37       * associated BeanInfo class.)
38       */
39      private String nameExpr;
40  
41      /***
42       * Getter method for "name" tag attribute. (Mapping set in associated
43       * BeanInfo class.)
44       */
45      public String getNameExpr() {
46          return (nameExpr);
47      }
48  
49      /***
50       * Setter method for "name" tag attribute. (Mapping set in associated
51       * BeanInfo class.)
52       */
53      public void setNameExpr(String nameExpr) {
54          this.nameExpr = nameExpr;
55      }
56  
57      /***
58       * Resets attribute values for tag reuse.
59       */
60      public void release() {
61          super.release();
62          setNameExpr(null);
63      }
64  
65      /***
66       * Process the start tag.
67       *
68       * @throws JspException if a JSP exception has occurred
69       */
70      public int doStartTag() throws JspException {
71          evaluateExpressions();
72  
73          return (super.doStartTag());
74      }
75  
76      /***
77       * Processes all attribute values which use the JSTL expression evaluation
78       * engine to determine their values.
79       *
80       * @throws JspException if a JSP exception has occurred
81       */
82      private void evaluateExpressions()
83          throws JspException {
84          String string = null;
85  
86          if ((string =
87                  EvalHelper.evalString("name", getNameExpr(), this, pageContext)) != null) {
88              setName(string);
89          }
90      }
91  }