You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by lu...@apache.org on 2001/12/18 03:43:28 UTC
cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/fmt MessageFormatTag.java
luehe 01/12/17 18:43:28
Modified: standard/conf fmt-rt.tld fmt.tld
standard/doc/web I18N_FunctionalDescription_6_EA3.html
standard/examples/web/format MessageFormat.jsp
standard/src/org/apache/taglibs/standard/tag/common/fmt
MessageFormatSupport.java MessageSupport.java
standard/src/org/apache/taglibs/standard/tag/el/fmt
MessageFormatTag.java
standard/src/org/apache/taglibs/standard/tag/rt/fmt
MessageFormatTag.java
Log:
Added 'messageArgs' attribute to <messageFormat>, to be consistent with <message>, which already supported this attribute
Revision Changes Path
1.8 +5 -0 jakarta-taglibs/standard/conf/fmt-rt.tld
Index: fmt-rt.tld
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/conf/fmt-rt.tld,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- fmt-rt.tld 2001/12/18 01:53:15 1.7
+++ fmt-rt.tld 2001/12/18 02:43:28 1.8
@@ -182,6 +182,11 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
+ <name>messageArgs</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
1.9 +6 -0 jakarta-taglibs/standard/conf/fmt.tld
Index: fmt.tld
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/conf/fmt.tld,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- fmt.tld 2001/12/18 01:53:15 1.8
+++ fmt.tld 2001/12/18 02:43:28 1.9
@@ -30,6 +30,7 @@
message:bundle
message:messageArgs
messageFormat:value
+ messageFormat:messageArgs
messageArg:value
formatNumber:value
formatNumber:pattern
@@ -224,6 +225,11 @@
</description>
<attribute>
<name>value</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>messageArgs</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
1.3 +22 -15 jakarta-taglibs/standard/doc/web/I18N_FunctionalDescription_6_EA3.html
Index: I18N_FunctionalDescription_6_EA3.html
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/doc/web/I18N_FunctionalDescription_6_EA3.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- I18N_FunctionalDescription_6_EA3.html 2001/12/18 01:53:15 1.2
+++ I18N_FunctionalDescription_6_EA3.html 2001/12/18 02:43:28 1.3
@@ -353,13 +353,16 @@
the current <tt>JspWriter
</tt>object.
<p>If the message corresponding to the given key is <i>compound</i>, that
-is, contains one or more variables, it can be supplied with argument values
-for these variables by using the <tt>messageArgs</tt> attribute or one
-or more <tt><messageArg></tt> subtags (one for each argument value).
-This procedure is referred to as
-<i>parametric replacement.</i> If the
-message is compound, but no <tt>messageArgs</tt> attribute or <tt><messageArg></tt>
-subtags are given, the message is left unmodified. Specifying a <tt><message></tt>
+is, contains one or more variables, it may be supplied with argument values
+for these variables via the <tt>messageArgs</tt> attribute or one or more
+<tt><messageArg></tt> subtags (one for each argument value). This procedure
+is referred to as
+<i>parametric replacement.</i> Parametric replacement
+takes place in the order of the argument values given via the <tt>messageArgs</tt>
+attribute or the
+<tt><messageArg></tt> subtags. If the message is compound,
+but neither a <tt>messageArgs</tt> attribute nor any <tt><messageArg></tt>
+subtags are specified, the message is left unmodified. Specifying a <tt><message></tt>
tag with both a <tt>messageArgs</tt> attribute and one or more <tt><messageArg></tt>
subtags causes a translation error.
<p>If the parent <tt><bundle></tt> action specifies a <tt>prefix</tt>
@@ -381,13 +384,17 @@
on a given pattern string , using the runtime's default locale.
<p>The pattern string may be specified via the <tt>value</tt> attribute;
if missing, it is read from the tag's body content.
-<p>The argument values for parametric replacement must be supplied via
+<p>The argument values for parametric replacement may be supplied via the
+<tt>messageArgs</tt> attribute or one or more
<tt><messageArg></tt>
-subtags. Each <tt><messageArg></tt> subtag replaces one parameter in
-the pattern. Parametric replacement takes place in the order of the
-<tt><messageArg></tt>
-subtags. If no <tt><messageArg></tt> subtag is given, the specified
-pattern is left unmodified.
+subtags (one for each parameter in the pattern). Parametric replacement
+takes place in the order of the argument values given via the <tt>messageArgs</tt>
+attribute or the
+<tt><messageArg></tt> subtags. If neither a <tt>messageArgs</tt>
+attribute nor any <tt><messageArg></tt> subtags are specified, the given
+pattern is left unmodified. Specifying a <tt><messageFormat></tt> tag
+with both a <tt>messageArgs</tt> attribute and one or more <tt><messageArg></tt>
+subtags causes a translation error.
<p>The result is output to the current <tt>JspWriter</tt> object, unless
the <tt>var</tt> attribute is given, in which case it is stored in the
named JSP attribute.
@@ -413,7 +420,7 @@
<br><tt> </c:forEach></tt>
<h3>
10. <messageArg></h3>
-The <tt><messageArg></tt> action provides one argument (for parametric
+The <tt><messageArg></tt> action provides a single argument (for parametric
replacement) to the compound message or pattern in its parent
<tt><message></tt>
or <tt><messageFormat></tt> action, respectively.
@@ -999,7 +1006,7 @@
<tr>
<td WIDTH="318"><b><tt><messageFormat></tt></b>
-<br><tt><font color="#000000"><b>value</b> var scope</font></tt>
+<br><tt><font color="#000000"><b>value</b> messageArgs var scope</font></tt>
<p>Performs parametric replacement on the pattern specified by the <tt>value</tt>
attribute using the argument values supplied via <tt><messageArg></tt>
subtags.</td>
1.4 +5 -0 jakarta-taglibs/standard/examples/web/format/MessageFormat.jsp
Index: MessageFormat.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/examples/web/format/MessageFormat.jsp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MessageFormat.jsp 2001/12/18 01:53:15 1.3
+++ MessageFormat.jsp 2001/12/18 02:43:28 1.4
@@ -28,6 +28,11 @@
<fmt:formatDate type="both"/>
</fmt:messageArg>
</fmt:messageFormat>
+
+ <li> Using 'messageArgs' attribute:<br>
+ <fmt:messageFormat messageArgs="$messageArgs">
+ Servlet container name/version: {0}
+ </fmt:messageFormat>
</ul>
</body>
1.3 +10 -5 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/MessageFormatSupport.java
Index: MessageFormatSupport.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/MessageFormatSupport.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MessageFormatSupport.java 2001/12/18 01:53:15 1.2
+++ MessageFormatSupport.java 2001/12/18 02:43:28 1.3
@@ -75,14 +75,15 @@
//*********************************************************************
// Protected state
- protected String value; // 'value' attribute
+ protected String value; // 'value' attribute
+ protected Object[] messageArgs; // 'messageArgs' attribute
//*********************************************************************
// Private state
- private String var; // 'var' attribute
- private int scope; // 'scope' attribute
+ private String var; // 'var' attribute
+ private int scope; // 'scope' attribute
private List arguments;
@@ -98,6 +99,7 @@
private void init() {
value = var = null;
scope = PageContext.PAGE_SCOPE;
+ messageArgs = null;
arguments.clear();
}
@@ -139,10 +141,13 @@
}
String message = value;
- if (!arguments.isEmpty()) {
+ // Perform parametric replacement if required
+ if (!arguments.isEmpty())
+ messageArgs = arguments.toArray();
+ if (messageArgs != null) {
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(value);
- message = formatter.format(arguments.toArray());
+ message = formatter.format(messageArgs);
}
if (var != null) {
1.4 +1 -1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/MessageSupport.java
Index: MessageSupport.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/MessageSupport.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MessageSupport.java 2001/12/18 01:53:15 1.3
+++ MessageSupport.java 2001/12/18 02:43:28 1.4
@@ -107,8 +107,8 @@
private void init() {
key = var = null;
bundle = null;
- messageArgs = null;
scope = PageContext.PAGE_SCOPE;
+ messageArgs = null;
arguments.clear();
}
1.2 +18 -2 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/fmt/MessageFormatTag.java
Index: MessageFormatTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/fmt/MessageFormatTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MessageFormatTag.java 2001/11/21 07:39:04 1.1
+++ MessageFormatTag.java 2001/12/18 02:43:28 1.2
@@ -71,9 +71,16 @@
public class MessageFormatTag extends MessageFormatSupport {
//*********************************************************************
+ // Private constants
+
+ private static final Class OBJECT_ARRAY_CLASS = new Object[0].getClass();
+
+
+ //*********************************************************************
// 'Private' state (implementation details)
- private String value_; // stores EL-based property
+ private String value_; // stores EL-based property
+ private String messageArgs_; // stores EL-based property
//*********************************************************************
@@ -118,14 +125,19 @@
this.value_ = value_;
}
+ // for EL-based attribute
+ public void setMessageArgs(String messageArgs_) {
+ this.messageArgs_ = messageArgs_;
+ }
+
//*********************************************************************
// Private (utility) methods
// (re)initializes state (during release() or construction)
private void init() {
// null implies "no expression"
- value_ = null;
+ value_ = messageArgs_ = null;
}
// Evaluates expressions as necessary
@@ -140,5 +152,9 @@
value = (String) ExpressionUtil.evalNotNull(
"message", "value", value_, String.class, this, pageContext);
+
+ messageArgs = (Object[]) ExpressionUtil.evalNotNull(
+ "messageFormat", "messageArgs", messageArgs_, OBJECT_ARRAY_CLASS,
+ this, pageContext);
}
}
1.2 +5 -0 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/fmt/MessageFormatTag.java
Index: MessageFormatTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/fmt/MessageFormatTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MessageFormatTag.java 2001/11/21 07:38:49 1.1
+++ MessageFormatTag.java 2001/12/18 02:43:28 1.2
@@ -76,4 +76,9 @@
public void setValue(String value) throws JspTagException {
this.value = value;
}
+
+ // for tag attribute
+ public void setMessageArgs(Object[] messageArgs) throws JspTagException {
+ this.messageArgs = messageArgs;
+ }
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>