View Javadoc

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