View Javadoc

1   /*
2    * $Id: ELForwardTag.java 376780 2006-02-10 18:09:22Z 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.logic;
19  
20  import org.apache.struts.taglib.logic.ForwardTag;
21  import org.apache.strutsel.taglib.utils.EvalHelper;
22  
23  import javax.servlet.jsp.JspException;
24  
25  /***
26   * Perform a forward or redirect to a page that is looked up in the
27   * configuration information associated with our application. <p> This class
28   * is a subclass of the class <code>org.apache.struts.taglib.logix.ForwardTag</code>
29   * which provides most of the described functionality.  This subclass allows
30   * all attribute values to be specified as expressions utilizing the
31   * JavaServer Pages Standard Library expression language.
32   *
33   * @version $Rev: 376780 $
34   */
35  public class ELForwardTag extends ForwardTag {
36      /***
37       * Instance variable mapped to "name" tag attribute. (Mapping set in
38       * associated BeanInfo class.)
39       */
40      private String nameExpr;
41  
42      /***
43       * Getter method for "name" tag attribute. (Mapping set in associated
44       * BeanInfo class.)
45       */
46      public String getNameExpr() {
47          return (nameExpr);
48      }
49  
50      /***
51       * Setter method for "name" tag attribute. (Mapping set in associated
52       * BeanInfo class.)
53       */
54      public void setNameExpr(String nameExpr) {
55          this.nameExpr = nameExpr;
56      }
57  
58      /***
59       * Resets attribute values for tag reuse.
60       */
61      public void release() {
62          super.release();
63          setNameExpr(null);
64      }
65  
66      /***
67       * Process the start tag.
68       *
69       * @throws JspException if a JSP exception has occurred
70       */
71      public int doStartTag() throws JspException {
72          evaluateExpressions();
73  
74          return (super.doStartTag());
75      }
76  
77      /***
78       * Processes all attribute values which use the JSTL expression evaluation
79       * engine to determine their values.
80       *
81       * @throws JspException if a JSP exception has occurred
82       */
83      private void evaluateExpressions()
84          throws JspException {
85          String string = null;
86  
87          if ((string =
88                  EvalHelper.evalString("name", getNameExpr(), this, pageContext)) != null) {
89              setName(string);
90          }
91      }
92  }