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:20:16 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/logic MessagesPresentTag.java

dgraham     2003/07/13 16:20:16

  Modified:    src/share/org/apache/struts/taglib/logic
                        MessagesPresentTag.java
  Log:
  Simplified condition() logic.
  
  Revision  Changes    Path
  1.7       +7 -21     jakarta-struts/src/share/org/apache/struts/taglib/logic/MessagesPresentTag.java
  
  Index: MessagesPresentTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/MessagesPresentTag.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MessagesPresentTag.java	5 Jan 2003 00:40:04 -0000	1.6
  +++ MessagesPresentTag.java	13 Jul 2003 23:20:16 -0000	1.7
  @@ -1,7 +1,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
  @@ -53,7 +53,6 @@
    *
    */
   
  -
   package org.apache.struts.taglib.logic;
   
   import java.util.Iterator;
  @@ -64,7 +63,6 @@
   import org.apache.struts.action.ActionMessages;
   import org.apache.struts.util.RequestUtils;
   
  -
   /**
    * Evalute to <code>true</code> if an <code>ActionMessages</code> class or a
    * class that can be converted to an <code>ActionMessages</code> class is in
  @@ -75,7 +73,6 @@
    * @version $Revision$ $Date$
    * @since Struts 1.1
    */
  -
   public class MessagesPresentTag extends ConditionalTagBase {
   
       /**
  @@ -125,15 +122,12 @@
       protected boolean condition(boolean desired) throws JspException {
           ActionMessages am = null;
   
  -        if (message != null && "true".equalsIgnoreCase(message))
  +        if (message != null && "true".equalsIgnoreCase(message)){
              name = Globals.MESSAGE_KEY;
  -
  -        // Evaluate the presence of the specified value
  -        boolean bMessages = false;
  +        }
   
           try {
  -            // Definitely know it should be an error so
  -            // use method to retrieve errors.
  +            // Definitely know it should be an error so use method to retrieve errors.
               if (Globals.ERROR_KEY.equals(name)) {
                   am = RequestUtils.getActionErrors(pageContext, name);
               } else {
  @@ -144,17 +138,9 @@
               throw e;
           }
   
  -        Iterator iterator = null;
  -
  -        if (property == null)
  -            iterator = am.get();
  -        else
  -            iterator = am.get(property);
  -
  -        if (iterator.hasNext())
  -           bMessages = true;
  +        Iterator iterator = (property == null) ? am.get() : am.get(property);
   
  -        return (bMessages == desired);
  +        return (iterator.hasNext() == desired);
   
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org