RE: Page scope bean and nested:iterate

2002-12-13 Thread Edgar P. Dollin
If you look at the tag, I believe it is keeping a reference to the
original property of the bean, and basing everything from that.

Edgar

-Original Message-
From: Jim Krygowski [mailto:[EMAIL PROTECTED]] 
Sent: Friday, December 13, 2002 11:39 AM
To: 'Struts Users Mailing List'
Subject: RE: Page scope bean and nested:iterate


Hi Sri-

Thanks for trying.  If I don't nest the element.getName() in the logic
tag it completely blows up with a big fat NullPointerException.  The
element is definitely not there.  I stepped through the code and it
looks like id is always getting removed from the page context!

This is the code that does the work:

if (iterator.hasNext()) {
Object element = iterator.next();
if (element == null)
pageContext.removeAttribute(id);
else
pageContext.setAttribute(id, element);
lengthCount++;
started = true;
if (indexId != null)
pageContext.setAttribute(indexId, new
Integer(getIndex()));
return (EVAL_BODY_TAG);
} else
return (SKIP_BODY);

element is always null (even though stuff is rendering on my JSP) so the
id is always getting pulled out of the pageContext.  But index id keeps
getting set.  This is pretty confusing,  I don't know if I should trust
my debugger or not, but it definitely looks like something strange is
going on.

All this makes me wonder if the Nested code is doing an end run around
the id and just passing references to the containing object to its
nested tags?

jk


> -Original Message-
> From: Sri Sankaran [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 13, 2002 11:24 AM
> To: Struts Users Mailing List
> Subject: RE: Page scope bean and nested:iterate
>
>
> The id attribute of the  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
>
> 
>
> 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:
>
>property="theBean">
>  
> <%=element.hashCode()%>
>  
>  
>  <%=currentIndex.intValue()%>
>
>   
>
> 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]>



--
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]>




RE: Page scope bean and nested:iterate

2002-12-13 Thread Sri Sankaran
Where did you derive the code snippet you sent?  Is it possible there is some name 
collision ('element')?

AFAIK, the nested tags simply set the stage (set the bean name and property) and 
delegate the actual iteration to their  counterpart.

Sri

-Original Message-
From: Jim Krygowski [mailto:[EMAIL PROTECTED]] 
Sent: Friday, December 13, 2002 11:39 AM
To: Struts Users Mailing List
Subject: RE: Page scope bean and nested:iterate


Hi Sri-

Thanks for trying.  If I don't nest the element.getName() in the logic tag it 
completely blows up with a big fat NullPointerException.  The element is definitely 
not there.  I stepped through the code and it looks like id is always getting removed 
from the page context!

This is the code that does the work:

if (iterator.hasNext()) {
Object element = iterator.next();
if (element == null)
pageContext.removeAttribute(id);
else
pageContext.setAttribute(id, element);
lengthCount++;
started = true;
if (indexId != null)
pageContext.setAttribute(indexId, new Integer(getIndex()));
return (EVAL_BODY_TAG);
} else
return (SKIP_BODY);

element is always null (even though stuff is rendering on my JSP) so the id is always 
getting pulled out of the pageContext.  But index id keeps getting set.  This is 
pretty confusing,  I don't know if I should trust my debugger or not, but it 
definitely looks like something strange is going on.

All this makes me wonder if the Nested code is doing an end run around the id and just 
passing references to the containing object to its nested tags?

jk


> -Original Message-
> From: Sri Sankaran [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 13, 2002 11:24 AM
> To: Struts Users Mailing List
> Subject: RE: Page scope bean and nested:iterate
>
>
> The id attribute of the  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
>
> 
>
> 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:
>
>property="theBean">
>  
> <%=element.hashCode()%>
>  
>  
>  <%=currentIndex.intValue()%>
>
>   
>
> 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]>



--
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]>




RE: Page scope bean and nested:iterate

2002-12-13 Thread Jim Krygowski
Hi Sri-

Thanks for trying.  If I don't nest the element.getName() in the logic tag
it completely blows up with a big fat NullPointerException.  The element is
definitely not there.  I stepped through the code and it looks like id is
always getting removed from the page context!

This is the code that does the work:

if (iterator.hasNext()) {
Object element = iterator.next();
if (element == null)
pageContext.removeAttribute(id);
else
pageContext.setAttribute(id, element);
lengthCount++;
started = true;
if (indexId != null)
pageContext.setAttribute(indexId, new Integer(getIndex()));
return (EVAL_BODY_TAG);
} else
return (SKIP_BODY);

element is always null (even though stuff is rendering on my JSP) so the id
is always getting pulled out of the pageContext.  But index id keeps getting
set.  This is pretty confusing,  I don't know if I should trust my debugger
or not, but it definitely looks like something strange is going on.

All this makes me wonder if the Nested code is doing an end run around the
id and just passing references to the containing object to its nested tags?

jk


> -Original Message-
> From: Sri Sankaran [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 13, 2002 11:24 AM
> To: Struts Users Mailing List
> Subject: RE: Page scope bean and nested:iterate
>
>
> The id attribute of the  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
>
> 
>
> 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:
>
>property="theBean">
>  
> <%=element.hashCode()%>
>  
>  
>  <%=currentIndex.intValue()%>
>
>   
>
> 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]>



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




RE: Page scope bean and nested:iterate

2002-12-13 Thread Sri Sankaran
The id attribute of the  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 



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:


   
<%=element.hashCode()%>
 
   
   <%=currentIndex.intValue()%>



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:   
For additional commands, e-mail: 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: