struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "SanJ.SANJAY" <girish...@gmail.com>
Subject Re: Struts logic:iterate does not recognize the collection.
Date Fri, 07 Nov 2008 18:45:00 GMT



newton.dave wrote:
> 
> The ">" characters are normally used to differentiate what I said from
> what you said. Prefacing *every* line with ">" somewhat defeats the
> purpose and breaks with tradition.
> 
> --- On Fri, 11/7/08, SanJ.SANJAY wrote:
>> I changed to put that in direct request also and did'nt work:
>> request.setAttribute("xxxCollection", xxxCollection);
> 
> You didn't answer my question; if you <logic:iterate...> over the
> collection without the <bean:write...> is there an iteration taking place?
> You can find out by putting a simple string inside the iterate tag and see
> if it prints at all. IIRC the iterate tag should search the appropriate
> scopes for the named collection.
> 
>> Ok, I have this question, do we really need to have the 
>> property in collection?
> 
> If you want the syntax you're using to work, yes. Your original code
> looked like this:
> 
> <bean:write name="iprecord" property="xxxCollection" />
> 
> IIRC that (more or less) means iprecord.getXxxCollection(), no? If you
> don't want to access a property of the iprecord element then you should
> leave off the "property" attribute:
> 
> <bean:write name="iprecord" />
> 
> This will just emit each item being iterated over. I have no real way of
> knowing what your intention is, however, without more information.
> 
> See [1], or the version appropriate for whatever Struts 1 version you're
> using.
> 
>> Can't I use collection with direct elements in it by setting that to
>> request? 
> 
> Sure, but that's not what you did.
> 
>> And if suppose  I use a property "filename" and add that to collection
>> "xxxCollection" and set the "xxxCollection" to request, all I need to do
>> is have this properties POJOS in form right? 
> 
> IIRC none of your sample code accessed the form, it just used scoped
> variables.
> 
> It might be easier to help if the missing bits of your example were
> posted.
> 
> Dave
> 
> [1] Struts 1.2.x <bean:write...> docs
>     http://struts.apache.org/1.2.x/userGuide/struts-bean.html#write
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

Ok answer to your question " if you <logic:iterate...> over the collection
without the <bean:write...> is there an iteration taking place? "     is
that it is not even goin inside the iterator I tried putting some string and
it did not show. I think the reason is that the moment it tries to read
proper xxxCollection in iterator tag, it throws error "bean xxxCollection is
not found in any any scope" 

<logic:iterator id="iprecord" name="xxxCollection">
<h1> Inside the iterator </h1>
</logic:iterate>

I am confused between "id" and "name" properties of this iterator tag. 

My requirement is very simple which is: 
I have a simple ArrayList xxxCollection that I populate in Action class and
set to the request.setAttribute(xxxCollection). This xxxCollection does not
contains any properties, it is just the collection of strings (filenames in
my case).

Now in JSP if I print this ArrayList xxxCollection using scriptlets 
<% out.print(request.getAttribute("xxxCollection")) %>  , it displays all
the values to the JSP page.

But if I use logic:iterator, it does'nt.

So what do you suggest here? what should be the "id" here if  "
name="xxCollection" "

 <logic:iterate id="??" name="xxCollection">
<bean:write name="xxCollection" />
</logic:iterate>

 Do you see anything wrong here Dave?
-- 
View this message in context: http://www.nabble.com/Struts-logic%3Aiterate-does-not-recognize-the-collection.-tp20385273p20386602.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Mime
View raw message