DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7313>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7313 [PATCH] logic:empty/notEmpty also deals with Collections Summary: [PATCH] logic:empty/notEmpty also deals with Collections Product: Struts Version: 1.1 Beta 1 Platform: All OS/Version: All Status: NEW Severity: Enhancement Priority: Other Component: Custom Tags AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I sent the following to struts-dev, but mysteriously my mail never made it to the list. The following is a minipatch against the current cvs that enables the logic:empty/notEmpty tag to also deal with Collections. Thanks for integrating it! Index: doc/userGuide/struts-logic.xml =================================================================== RCS file: /home/cvspublic/jakarta-struts/doc/userGuide/struts-logic.xml,v retrieving revision 1.2 diff -c -r1.2 struts-logic.xml *** doc/userGuide/struts-logic.xml 16 Mar 2002 03:00:44 -0000 1.2 --- doc/userGuide/struts-logic.xml 19 Mar 2002 10:51:12 -0000 *************** *** 72,85 **** <name>empty</name> <summary> Evaluate the nested body content of this tag if the requested variable is ! either <code>null</code> or an empty string. </summary> <tagclass>org.apache.struts.taglib.logic.EmptyTag</tagclass> <bodycontent>JSP</bodycontent> <info> <p>[Since 1.1] This tag evaluates its nested body content only if the specified value is either absent (i.e. <code>null</code>) or an empty string (i.e. a ! <code>java.lang.String</code> with a length of zero).</p> </info> <attribute> --- 72,86 ---- <name>empty</name> <summary> Evaluate the nested body content of this tag if the requested variable is ! either <code>null</code> or an empty string or an empty collection. </summary> <tagclass>org.apache.struts.taglib.logic.EmptyTag</tagclass> <bodycontent>JSP</bodycontent> <info> <p>[Since 1.1] This tag evaluates its nested body content only if the specified value is either absent (i.e. <code>null</code>) or an empty string (i.e. a ! <code>java.lang.String</code> with a length of zero) or an empty ! <code>java.lang.Collection</code>.</p> </info> <attribute> *************** *** 1008,1021 **** <name>notEmpty</name> <summary> Evaluate the nested body content of this tag if the requested variable is ! neither <code>null</code> nor an empty string. </summary> <tagclass>org.apache.struts.taglib.logic.NotEmptyTag</tagclass> <bodycontent>JSP</bodycontent> <info> <p>This tag evaluates its nested body content only if the specified value is present (i.e. not <code>null</code>) and is not an empty string (i.e. a ! <code>java.lang.String</code> with a length of zero).</p> </info> <attribute> --- 1009,1023 ---- <name>notEmpty</name> <summary> Evaluate the nested body content of this tag if the requested variable is ! neither <code>null</code> nor an empty string nor an empty collection. </summary> <tagclass>org.apache.struts.taglib.logic.NotEmptyTag</tagclass> <bodycontent>JSP</bodycontent> <info> <p>This tag evaluates its nested body content only if the specified value is present (i.e. not <code>null</code>) and is not an empty string (i.e. a ! <code>java.lang.String</code> with a length of zero) and is not an empty ! <code>java.lang.Collection</code>.</p> </info> <attribute> Index: src/share/org/apache/struts/taglib/logic/EmptyTag.java =================================================================== RCS file: /home/cvspublic/jakarta- struts/src/share/org/apache/struts/taglib/logic/EmptyTag.java,v retrieving revision 1.1 diff -c -r1.1 EmptyTag.java *** src/share/org/apache/struts/taglib/logic/EmptyTag.java 8 Jul 2001 04:15:13 -0000 1.1 --- src/share/org/apache/struts/taglib/logic/EmptyTag.java 19 Mar 2002 10:51:12 -0000 *************** *** 63,68 **** --- 63,69 ---- package org.apache.struts.taglib.logic; + import java.util.Collection; import javax.servlet.jsp.JspException; import org.apache.struts.util.RequestUtils; *************** *** 117,122 **** --- 118,126 ---- if (value instanceof String) { String strValue = (String)value; empty = (strValue.length() < 1); + } else if (value instanceof Collection) { + Collection collValue = (Collection)value; + empty = collValue.isEmpty(); } else { empty = false; } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>