struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sri Sankaran" <Sri.Sanka...@sas.com>
Subject RE: Page scope bean and nested:iterate
Date Fri, 13 Dec 2002 16:24:20 GMT
The id attribute of the <nested:iterate> is a handle to the current element in the iteration.
 So, by definition, the reference cannot be null -- 'cos if it were, you'd be out of the iteration.
 Make sense?  So, methinks you *shouldn't* need to test if it is present. 

I know all this doesn't explain your NPE.

Just for grins can you try changing the 

<nested:write property="name"/>

to

<%=element.getName()%>

If 'element' is null, *that* should blow up too.  I am puzzled as to how the bean at element
can be null.

Sorry if this didn't help any bit.

Sri

-----Original Message-----
From: Jim Krygowski [mailto:james.krygowski@shaws.com] 
Sent: Friday, December 13, 2002 10:51 AM
To: Struts Users Mailing List
Subject: Page scope bean and nested:iterate


Hi-

I'm using nested:iterate and have not been successful in using the id attribute of the iterate
tag.  The documentation for nested:iterate is just the documentation for logic:iterate so
I would imagine that nested:iterate should support id.

I have some code like where theBean is the source of the objects I'm iterating over:

	<nested:iterate id="element" indexId="currentIndex" property="theBean">
	   <logic:present name="element">
            <%=element.hashCode()%><br>
         </logic:present>
	   <nested:write property="name"/><br>
	   <%=currentIndex.intValue()%>

	</nested:iterate>

The following code runs and outputs just the value of the name and the current index number.
 If I removed the logic:present, I get a runtime error because element is null.  I think this
should work, but it doesn't.  Why?


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message