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:[EMAIL PROTECTED]] 
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:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to