dwinterfeldt 01/10/16 08:43:58
Modified: src/share/org/apache/struts/taglib/html ErrorsTag.java
MessagesTag.java LocalStrings.properties
Log:
The logic for creating an ActionErrors or ActionMessages object has been moved to a
utility method in RequestUtils. The JspException message is also generated in
RequestUtils.
Revision Changes Path
1.12 +11 -36
jakarta-struts/src/share/org/apache/struts/taglib/html/ErrorsTag.java
Index: ErrorsTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ErrorsTag.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ErrorsTag.java 2001/07/16 00:44:54 1.11
+++ ErrorsTag.java 2001/10/16 15:43:58 1.12
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ErrorsTag.java,v 1.11
2001/07/16 00:44:54 craigmcc Exp $
- * $Revision: 1.11 $
- * $Date: 2001/07/16 00:44:54 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ErrorsTag.java,v 1.12
2001/10/16 15:43:58 dwinterfeldt Exp $
+ * $Revision: 1.12 $
+ * $Date: 2001/10/16 15:43:58 $
*
* ====================================================================
*
@@ -98,7 +98,7 @@
* </ul>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.11 $ $Date: 2001/07/16 00:44:54 $
+ * @version $Revision: 1.12 $ $Date: 2001/10/16 15:43:58 $
*/
public class ErrorsTag extends TagSupport {
@@ -189,39 +189,14 @@
public int doStartTag() throws JspException {
// Were any error messages specified?
- ActionErrors errors = new ActionErrors();
+ ActionErrors errors = null;
try {
- Object value = pageContext.getAttribute
- (name, PageContext.REQUEST_SCOPE);
- if (value == null) {
- ;
- } else if (value instanceof String) {
- errors.add(ActionErrors.GLOBAL_ERROR,
- new ActionError((String) value));
- } else if (value instanceof String[]) {
- String keys[] = (String[]) value;
- for (int i = 0; i < keys.length; i++)
- errors.add(ActionErrors.GLOBAL_ERROR,
- new ActionError(keys[i]));
- } else if (value instanceof ErrorMessages) {
- String keys[] = ((ErrorMessages) value).getErrors();
- if (keys == null)
- keys = new String[0];
- for (int i = 0; i < keys.length; i++)
- errors.add(ActionErrors.GLOBAL_ERROR,
- new ActionError(keys[i]));
- } else if (value instanceof ActionErrors) {
- errors = (ActionErrors) value;
- } else {
- JspException e = new JspException
- (messages.getMessage("errorsTag.errors",
- value.getClass().getName()));
- RequestUtils.saveException(pageContext, e);
- throw e;
- }
- } catch (Exception e) {
- ;
- }
+ errors = RequestUtils.getActionErrors(pageContext, name);
+ } catch (JspException e) {
+ RequestUtils.saveException(pageContext, e);
+ throw e;
+ }
+
if (errors.empty())
return (EVAL_BODY_INCLUDE);
1.3 +15 -41
jakarta-struts/src/share/org/apache/struts/taglib/html/MessagesTag.java
Index: MessagesTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/MessagesTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MessagesTag.java 2001/09/17 19:59:30 1.2
+++ MessagesTag.java 2001/10/16 15:43:58 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/MessagesTag.java,v
1.2 2001/09/17 19:59:30 husted Exp $
- * $Revision: 1.2 $
- * $Date: 2001/09/17 19:59:30 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/MessagesTag.java,v
1.3 2001/10/16 15:43:58 dwinterfeldt Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/10/16 15:43:58 $
*
* ====================================================================
*
@@ -86,7 +86,7 @@
*
* @since 1.1
* @author David Winterfeldt
- * @version $Revision: 1.2 $ $Date: 2001/09/17 19:59:30 $
+ * @version $Revision: 1.3 $ $Date: 2001/10/16 15:43:58 $
*/
public class MessagesTag extends BodyTagSupport {
@@ -224,44 +224,18 @@
* @exception JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
- // Were any messages specified?
- ActionMessages messages = new ActionMessages();
-
- if (message != null && "true".equalsIgnoreCase(message))
- name = Action.MESSAGE_KEY;
-
- try {
- Object value = pageContext.getAttribute
- (name, PageContext.REQUEST_SCOPE);
- if (value == null) {
- ;
- } else if (value instanceof String) {
- messages.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage((String) value));
- } else if (value instanceof String[]) {
- String keys[] = (String[]) value;
- for (int i = 0; i < keys.length; i++)
- messages.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage(keys[i]));
- } else if (value instanceof ErrorMessages) {
- String keys[] = ((ErrorMessages) value).getErrors();
- if (keys == null)
- keys = new String[0];
- for (int i = 0; i < keys.length; i++)
- messages.add(ActionErrors.GLOBAL_ERROR,
- new ActionError(keys[i]));
- } else if (value instanceof ActionMessages) {
- messages = (ActionMessages) value;
- } else {
- JspException e = new JspException
- (messageResources.getMessage("messagesTag.errors",
- value.getClass().getName()));
- RequestUtils.saveException(pageContext, e);
- throw e;
+ // Were any messages specified?
+ ActionMessages messages = null;
+
+ if (message != null && "true".equalsIgnoreCase(message))
+ name = Action.MESSAGE_KEY;
+
+ try {
+ messages = RequestUtils.getActionMessages(pageContext, name);
+ } catch (JspException e) {
+ RequestUtils.saveException(pageContext, e);
+ throw e;
}
- } catch (Exception e) {
- ;
- }
// Acquire the collection we are going to iterate over
if (property == null)
1.12 +0 -2
jakarta-struts/src/share/org/apache/struts/taglib/html/LocalStrings.properties
Index: LocalStrings.properties
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/LocalStrings.properties,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- LocalStrings.properties 2001/07/24 11:42:15 1.11
+++ LocalStrings.properties 2001/10/16 15:43:58 1.12
@@ -1,6 +1,5 @@
common.io=Encountered input/output error: {0}
enumerateTag.enumeration=Cannot create enumeration for {0}
-errorsTag.errors=Cannot process ActionErrors instance of class {0}
formTag.collections=Cannot find ActionMappings or ActionFormBeans collection
formTag.create=Exception creating bean of class {0}: {1}
formTag.formBean=Cannot retrieve definition for form bean {0}
@@ -30,7 +29,6 @@
linkTag.url=Cannot create link URL: {0}
messageTag.message=Missing message for key {0}
messageTag.resources=Missing resources attribute {0}
-messagesTag.errors=Cannot process ActionMessages instance of class {0}
multiboxTag.value=You must specify the value attribute or nested tag content
optionTag.select=Option tag must be nested in a Select tag
optionsTag.enumeration=Cannot create enumeration for {0}