martinc 01/06/13 21:25:34
Modified: doc struts-logic.xml
src/share/org/apache/struts/taglib/logic IterateTag.java
IterateTei.java
Log:
Port new 'indexId' attribute.
Revision Changes Path
1.7 +9 -0 jakarta-struts/doc/struts-logic.xml
Index: struts-logic.xml
===================================================================
RCS file: /home/cvs/jakarta-struts/doc/struts-logic.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- struts-logic.xml 2001/05/09 19:31:02 1.6
+++ struts-logic.xml 2001/06/14 04:25:31 1.7
@@ -465,6 +465,15 @@
</attribute>
<attribute>
+ <name>indexId</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>
+ <p>The name of a page scope JSP bean that will contain the current
+ index of the collection on each iteration.</p>
+ </info>
+ </attribute>
+ <attribute>
<name>length</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
1.12 +22 -4
jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java
Index: IterateTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- IterateTag.java 2001/04/29 01:26:19 1.11
+++ IterateTag.java 2001/06/14 04:25:32 1.12
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java,v
1.11 2001/04/29 01:26:19 craigmcc Exp $
- * $Revision: 1.11 $
- * $Date: 2001/04/29 01:26:19 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java,v
1.12 2001/06/14 04:25:32 martinc Exp $
+ * $Revision: 1.12 $
+ * $Date: 2001/06/14 04:25:32 $
*
* ====================================================================
*
@@ -88,7 +88,7 @@
* or a Map (which includes Hashtables) whose elements will be iterated over.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.11 $ $Date: 2001/04/29 01:26:19 $
+ * @version $Revision: 1.12 $ $Date: 2001/06/14 04:25:32 $
*/
public class IterateTag extends BodyTagSupport {
@@ -188,6 +188,20 @@
/**
+ * The name of the scripting variable to be exposed as the current index.
+ */
+ protected String indexId = null;
+
+ public String getIndexId() {
+ return (this.indexId);
+ }
+
+ public void setIndexId(String indexId) {
+ this.indexId = indexId;
+ }
+
+
+ /**
* The length value or attribute name (<=0 means no limit).
*/
protected String length = null;
@@ -366,6 +380,8 @@
pageContext.setAttribute(id, element);
lengthCount++;
started = true;
+ if (indexId != null)
+ pageContext.setAttribute(indexId, new Integer(getIndex()));
return (EVAL_BODY_TAG);
} else
return (SKIP_BODY);
@@ -397,6 +413,8 @@
else
pageContext.setAttribute(id, element);
lengthCount++;
+ if (indexId != null)
+ pageContext.setAttribute(indexId, new Integer(getIndex()));
return (EVAL_BODY_TAG);
} else
return (SKIP_BODY);
1.5 +24 -11
jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTei.java
Index: IterateTei.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTei.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IterateTei.java 2001/02/12 21:49:56 1.4
+++ IterateTei.java 2001/06/14 04:25:33 1.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTei.java,v
1.4 2001/02/12 21:49:56 craigmcc Exp $
- * $Revision: 1.4 $
- * $Date: 2001/02/12 21:49:56 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTei.java,v
1.5 2001/06/14 04:25:33 martinc Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/06/14 04:25:33 $
*
* ====================================================================
*
@@ -73,7 +73,7 @@
* tag, identifying the scripting object(s) to be made visible.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.4 $ $Date: 2001/02/12 21:49:56 $
+ * @version $Revision: 1.5 $ $Date: 2001/06/14 04:25:33 $
*/
public class IterateTei extends TagExtraInfo {
@@ -87,13 +87,26 @@
String type = data.getAttributeString("type");
if (type == null)
type = "java.lang.Object";
-
- return new VariableInfo[] {
- new VariableInfo(data.getAttributeString("id"),
- type,
- true,
- VariableInfo.NESTED)
- };
+ VariableInfo typeInfo = new VariableInfo(
+ data.getAttributeString("id"),
+ type,
+ true,
+ VariableInfo.NESTED);
+
+ String indexId = data.getAttributeString("indexId");
+ VariableInfo indexIdInfo = null;
+ if (indexId != null)
+ indexIdInfo = new VariableInfo(
+ indexId,
+ "java.lang.Integer",
+ true,
+ VariableInfo.NESTED);
+
+ if (indexIdInfo == null) {
+ return new VariableInfo[] { typeInfo };
+ } else {
+ return new VariableInfo[] { typeInfo, indexIdInfo };
+ }
}