husted 2004/06/25 17:22:59 Modified: src/share/org/apache/struts/taglib/logic EmptyTag.java Log: Apply #29448 "EmptyTag does not worth with Arrays" submitted by Dave King Revision Changes Path 1.14 +28 -23 jakarta-struts/src/share/org/apache/struts/taglib/logic/EmptyTag.java Index: EmptyTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/EmptyTag.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- EmptyTag.java 14 Mar 2004 06:23:44 -0000 1.13 +++ EmptyTag.java 26 Jun 2004 00:22:59 -0000 1.14 @@ -4,13 +4,13 @@ * $Date$ * * Copyright 1999-2004 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,8 +22,10 @@ import java.util.Collection; import java.util.Map; +import java.lang.reflect.Array; import javax.servlet.jsp.JspException; + import org.apache.struts.taglib.TagUtils; /** @@ -65,22 +67,22 @@ * @exception JspException if a JSP exception occurs */ protected boolean condition(boolean desired) throws JspException { - if (this.name == null) { - JspException e = - new JspException(messages.getMessage("empty.noNameAttribute")); - TagUtils.getInstance().saveException(pageContext, e); - throw e; - } - - Object value = null; - if (this.property == null) { - value = TagUtils.getInstance().lookup(pageContext, name, scope); - } else { - value = TagUtils.getInstance().lookup(pageContext, name, property, scope); - } - + if (this.name == null) { + JspException e = + new JspException(messages.getMessage("empty.noNameAttribute")); + TagUtils.getInstance().saveException(pageContext, e); + throw e; + } + + Object value = null; + if (this.property == null) { + value = TagUtils.getInstance().lookup(pageContext, name, scope); + } else { + value = TagUtils.getInstance().lookup(pageContext, name, property, scope); + } + boolean empty = true; - + if (value == null) { empty = true; @@ -96,11 +98,14 @@ Map mapValue = (Map) value; empty = mapValue.isEmpty(); + } else if (value.getClass().isArray()) { + empty = Array.getLength(value) == 0; + } else { empty = false; } - return (empty == desired); + return (empty == desired); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]