KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > standard > tag > el > fmt > SetBundleTag


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.standard.tag.el.fmt;
18
19 import javax.servlet.jsp.JspException JavaDoc;
20
21 import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
22 import org.apache.taglibs.standard.tag.common.fmt.SetBundleSupport;
23
24 /**
25  * <p>A handler for &lt;setBundle&gt; that accepts attributes as Strings
26  * and evaluates them as expressions at runtime.</p>
27  *
28  * @author Shawn Bayern
29  * @author Jan Luehe
30  */

31
32 public class SetBundleTag extends SetBundleSupport {
33
34     //*********************************************************************
35
// 'Private' state (implementation details)
36

37     private String JavaDoc basename_; // stores EL-based property
38

39
40     //*********************************************************************
41
// Constructor
42

43     /**
44      * Constructs a new SetBundleTag. As with TagSupport, subclasses
45      * should not provide other constructors and are expected to call
46      * the superclass constructor
47      */

48     public SetBundleTag() {
49         super();
50         init();
51     }
52
53
54     //*********************************************************************
55
// Tag logic
56

57     // evaluates expression and chains to parent
58
public int doStartTag() throws JspException JavaDoc {
59
60         // evaluate any expressions we were passed, once per invocation
61
evaluateExpressions();
62
63     // chain to the parent implementation
64
return super.doStartTag();
65     }
66
67     // Releases any resources we may have (or inherit)
68
public void release() {
69         super.release();
70         init();
71     }
72
73
74     //*********************************************************************
75
// Accessor methods
76

77     // for EL-based attribute
78
public void setBasename(String JavaDoc basename_) {
79         this.basename_ = basename_;
80     }
81
82
83     //*********************************************************************
84
// Private (utility) methods
85

86     // (re)initializes state (during release() or construction)
87
private void init() {
88         // null implies "no expression"
89
basename_ = null;
90     }
91
92     // Evaluates expressions as necessary
93
private void evaluateExpressions() throws JspException JavaDoc {
94
95     // 'basename' attribute (mandatory)
96
basename = (String JavaDoc) ExpressionEvaluatorManager.evaluate(
97         "basename", basename_, String JavaDoc.class, this, pageContext);
98     }
99 }
100
Popular Tags