You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by dg...@apache.org on 2003/07/14 01:55:00 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/bean MessageTag.java
dgraham 2003/07/13 16:55:00
Modified: src/share/org/apache/struts/taglib/bean MessageTag.java
Log:
Fixed formatting.
Revision Changes Path
1.11 +63 -79 jakarta-struts/src/share/org/apache/struts/taglib/bean/MessageTag.java
Index: MessageTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/MessageTag.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- MessageTag.java 11 Mar 2003 00:00:28 -0000 1.10
+++ MessageTag.java 13 Jul 2003 23:55:00 -0000 1.11
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,10 +59,8 @@
*
*/
-
package org.apache.struts.taglib.bean;
-
import java.util.Locale;
import javax.servlet.jsp.JspException;
@@ -73,7 +71,6 @@
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
-
/**
* Custom tag that retrieves an internationalized messages string (with
* optional parametric replacement) from the <code>ActionResources</code>
@@ -83,117 +80,106 @@
* @author Craig R. McClanahan
* @version $Revision$ $Date$
*/
-
public class MessageTag extends TagSupport {
-
// ------------------------------------------------------------- Properties
-
/**
* The first optional argument.
*/
protected String arg0 = null;
public String getArg0() {
- return (this.arg0);
+ return (this.arg0);
}
public void setArg0(String arg0) {
- this.arg0 = arg0;
+ this.arg0 = arg0;
}
-
/**
* The second optional argument.
*/
protected String arg1 = null;
public String getArg1() {
- return (this.arg1);
+ return (this.arg1);
}
public void setArg1(String arg1) {
- this.arg1 = arg1;
+ this.arg1 = arg1;
}
-
/**
* The third optional argument.
*/
protected String arg2 = null;
public String getArg2() {
- return (this.arg2);
+ return (this.arg2);
}
public void setArg2(String arg2) {
- this.arg2 = arg2;
+ this.arg2 = arg2;
}
-
/**
* The fourth optional argument.
*/
protected String arg3 = null;
public String getArg3() {
- return (this.arg3);
+ return (this.arg3);
}
public void setArg3(String arg3) {
- this.arg3 = arg3;
+ this.arg3 = arg3;
}
-
/**
* The fifth optional argument.
*/
protected String arg4 = null;
public String getArg4() {
- return (this.arg4);
+ return (this.arg4);
}
public void setArg4(String arg4) {
- this.arg4 = arg4;
+ this.arg4 = arg4;
}
-
/**
* The servlet context attribute key for our resources.
*/
protected String bundle = null;
public String getBundle() {
- return (this.bundle);
+ return (this.bundle);
}
public void setBundle(String bundle) {
- this.bundle = bundle;
+ this.bundle = bundle;
}
-
/**
* The default Locale for our server.
*/
protected static final Locale defaultLocale = Locale.getDefault();
-
/**
* The message key of the message to be retrieved.
*/
protected String key = null;
public String getKey() {
- return (this.key);
+ return (this.key);
}
public void setKey(String key) {
- this.key = key;
+ this.key = key;
}
-
/**
* Name of the bean that contains the message key.
*/
@@ -207,7 +193,6 @@
this.name = name;
}
-
/**
* Name of the property to be accessed on the specified bean.
*/
@@ -221,7 +206,6 @@
this.property = property;
}
-
/**
* The scope to be searched to retrieve the specified bean.
*/
@@ -235,32 +219,28 @@
this.scope = scope;
}
-
/**
* The session scope key under which our Locale is stored.
*/
protected String localeKey = Globals.LOCALE_KEY;
public String getLocale() {
- return (this.localeKey);
+ return (this.localeKey);
}
public void setLocale(String localeKey) {
- this.localeKey = localeKey;
+ this.localeKey = localeKey;
}
-
/**
* The message resources for this package.
*/
protected static MessageResources messages =
- MessageResources.getMessageResources
- ("org.apache.struts.taglib.bean.LocalStrings");
-
+ MessageResources.getMessageResources(
+ "org.apache.struts.taglib.bean.LocalStrings");
// --------------------------------------------------------- Public Methods
-
/**
* Process the start tag.
*
@@ -271,63 +251,67 @@
String key = this.key;
if (key == null) {
// Look up the requested property value
- Object value =
- RequestUtils.lookup(pageContext, name, property, scope);
+ Object value = RequestUtils.lookup(pageContext, name, property, scope);
if (value != null && !(value instanceof String)) {
- JspException e = new JspException
- (messages.getMessage("message.property", key));
+ JspException e =
+ new JspException(messages.getMessage("message.property", key));
RequestUtils.saveException(pageContext, e);
throw e;
}
- key = (String)value;
+ key = (String) value;
}
- // Construct the optional arguments array we will be using
- Object args[] = new Object[5];
- args[0] = arg0;
- args[1] = arg1;
- args[2] = arg2;
- args[3] = arg3;
- args[4] = arg4;
-
- // Retrieve the message string we are looking for
- String message = RequestUtils.message(pageContext, this.bundle,
- this.localeKey, key, args);
- if (message == null) {
- JspException e = new JspException
- (messages.getMessage("message.message", "\"" + key + "\""));
+ // Construct the optional arguments array we will be using
+ Object args[] = new Object[5];
+ args[0] = arg0;
+ args[1] = arg1;
+ args[2] = arg2;
+ args[3] = arg3;
+ args[4] = arg4;
+
+ // Retrieve the message string we are looking for
+ String message =
+ RequestUtils.message(
+ pageContext,
+ this.bundle,
+ this.localeKey,
+ key,
+ args);
+
+ if (message == null) {
+ JspException e =
+ new JspException(
+ messages.getMessage("message.message", "\"" + key + "\""));
RequestUtils.saveException(pageContext, e);
throw e;
}
- // Print the retrieved message to our output writer
+ // Print the retrieved message to our output writer
ResponseUtils.write(pageContext, message);
- // Continue processing this page
- return (SKIP_BODY);
+ // Continue processing this page
+ return (SKIP_BODY);
}
-
/**
* Release any acquired resources.
*/
public void release() {
- super.release();
- arg0 = null;
- arg1 = null;
- arg2 = null;
- arg3 = null;
- arg4 = null;
- bundle = Globals.MESSAGES_KEY;
- key = null;
- name = null;
- property = null;
- scope = null;
- localeKey = Globals.LOCALE_KEY;
+ super.release();
+ arg0 = null;
+ arg1 = null;
+ arg2 = null;
+ arg3 = null;
+ arg4 = null;
+ bundle = Globals.MESSAGES_KEY;
+ key = null;
+ name = null;
+ property = null;
+ scope = null;
+ localeKey = Globals.LOCALE_KEY;
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org