1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.fmt;
17
18 import org.apache.commons.jelly.JellyTagException;
19 import org.apache.commons.jelly.XMLOutput;
20 import org.apache.commons.jelly.TagSupport;
21 import org.apache.commons.jelly.expression.Expression;
22 import java.util.Locale;
23
24 /***
25 * Support for tag handlers for <setLocale>, the bundle setting
26 * tag in JSTL.
27 * @author <a href="mailto:willievu@yahoo.com">Willie Vu</a>
28 * @version $Revision: 155420 $
29 *
30 */
31 public class SetBundleTag extends TagSupport {
32
33 private String var;
34
35 private Expression basename;
36
37 private String scope;
38
39 /*** Creates a new instance of SetBundleTag */
40 public SetBundleTag() {
41 }
42
43 /***
44 * Evaluates this tag after all the tags properties have been initialized.
45 *
46 */
47 public void doTag(XMLOutput output) throws JellyTagException {
48 Object basenameInput = null;
49 if (this.basename != null) {
50 basenameInput = this.basename.evaluate(context);
51 }
52
53 LocalizationContext locCtxt = BundleTag.getLocalizationContext(
54 context, (String) basenameInput);
55
56 String varname = (var != null) ? var : Config.FMT_LOCALIZATION_CONTEXT;
57
58 if (scope != null) {
59 context.setVariable(varname, scope, locCtxt);
60 }
61 else {
62 context.setVariable(varname, locCtxt);
63 }
64 }
65
66 public void setVar(String var) {
67 this.var = var;
68 }
69
70 public void setBasename(Expression basename) {
71 this.basename = basename;
72 }
73
74 public void setScope(String scope) {
75 this.scope = scope;
76 }
77 }