01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.tags.databinding.message;
20:
21: import javax.servlet.jsp.JspException;
22: import javax.servlet.jsp.PageContext;
23:
24: import org.apache.beehive.netui.tags.AbstractClassicTag;
25:
26: /**
27: * <p>
28: * This tag should be used in conjunction with the {@link Message} tag to provide a message argument to the
29: * message format provided in the {@link Message#setValue(Object)} method. Before formatting, the
30: * value of this tag will be substituted into the message.
31: * </p>
32: *
33: * @jsptagref.tagdescription
34: * <p>
35: * This tag should be used in conjunction with the {@link Message} tag to provide a message argument to the
36: * message format provided in the {@link Message#setValue(Object)} method. Before formatting, the
37: * value of this tag will be substituted into the message.
38: * </p>
39: * @example
40: * <p>For an example that uses the <netui-data:messageArg> tag, see the {@link Message} description.
41: * @deprecated This tag has been deprecated in favor of the i18n tags available in JSTL.
42: * @netui:tag name="messageArg"
43: * deprecated="true"
44: * description="Allows you to set values that are used as arguments to the Message tag. The formatted message results are available to the page context."
45: */
46: public class MessageArg extends AbstractClassicTag {
47:
48: private Object _value = null;
49:
50: public String getTagName() {
51: return "MessageArg";
52: }
53:
54: /**
55: * @jsptagref.attributedescription A string value for the argument.
56: * @jsptagref.attributesyntaxvalue <i>string_argument</i>
57: * @netui:attribute required="true" rtexprvalue="true"
58: */
59: public void setValue(Object value) {
60: this ._value = value;
61: }
62:
63: public int doStartTag() throws JspException {
64: // verify parent tag
65: if (!(getParent() instanceof Message)) {
66: throw new JspException("Invalid Parent");
67: }
68:
69: return EVAL_BODY_BUFFERED;
70: }
71:
72: public int doEndTag() throws JspException {
73: if (hasErrors())
74: reportErrors();
75: else
76: ((Message) getParent()).addMessageArgument(_value);
77:
78: localRelease();
79:
80: return EVAL_PAGE;
81: }
82:
83: protected void localRelease() {
84: super.localRelease();
85: _value = null;
86: }
87: }
|