Struts logic:iterate does not recognize the collection.

2008-11-07 Thread SanJ.SANJAY

 I am trying to display the collection that I am setting in struts action to
the request scope.
 But when I try to use struts logic:iterate to display the collection,
 it says does not find xxxCollection bean in any scope.

In Action class:
 for (int i = 0; i  children.length; i++)
{ xxxCollection.add(filename); }
request.getSession().setAttribute(xxxCollection, xxxCollection);

I have getter and setters for this collection in the form.

 But In JSP, it does not recognize the collection:

logic:iterate id=iprecord indexId=ind name=xxxCollection 
 bean:write name=iprecord property=xxxCollection /
/logic:iterate

I am clueless about why the bean is invisible??

-- 
View this message in context: 
http://www.nabble.com/Struts-logic%3Aiterate-does-not-recognize-the-collection.-tp20385273p20385273.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



Re: Struts logic:iterate does not recognize the collection.

2008-11-07 Thread Dave Newton
--- On Fri, 11/7/08, SanJ.SANJAY wrote:
 I am trying to display the collection that I am setting in
 struts action to the request scope.

The code is putting it in session scope, FWIW:

 request.getSession().setAttribute(xxxCollection, xxxCollection);
 [...]
 logic:iterate id=iprecord indexId=ind name=xxxCollection 
   bean:write name=iprecord property=xxxCollection /
 /logic:iterate

Does it not recognize the *collection*? In other words, is it not iterating at 
all? Or is the bean:write... funky: does each element of xxxCollection have 
an xxxCollection property and is printing that what you really mean to do?

Dave


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



Re: Struts logic:iterate does not recognize the collection.

2008-11-07 Thread SanJ.SANJAY



newton.dave wrote:
 
 --- On Fri, 11/7/08, SanJ.SANJAY wrote:
 I am trying to display the collection that I am setting in
 struts action to the request scope.
 
 The code is putting it in session scope, FWIW:
 
 request.getSession().setAttribute(xxxCollection, xxxCollection);
 [...]
 logic:iterate id=iprecord indexId=ind name=xxxCollection 
   bean:write name=iprecord property=xxxCollection /
 /logic:iterate
 
 Does it not recognize the *collection*? In other words, is it not
 iterating at all? Or is the bean:write... funky: does each element of
 xxxCollection have an xxxCollection property and is printing that what you
 really mean to do?
 
 Dave
 
 I changed to put that in direct request also and did'nt work:
  request.setAttribute(xxxCollection, xxxCollection);
 
 I could see the elements of collection when I use java in jsp using
 scriptlets (%%) and in the same page if I use struts logic:iterate ,
 it does'nt see the bean.
 
Does it not recognize the *collection*? In other words, is it not
iterating at all? Or is the bean:write... funky: does each element of
xxxCollection have an xxxCollection property and is printing that what you
really mean to do?
 
 Ok, I have this question, do we really need to have the property in
 collection? Can't I use collection with direct elements in it by setting
 that to request? 
 ex.
 
 for(int i=0;i=list.size();i++) {
 xxxCollection.add(i);
 }
 
 request.setAttribute(xxxCollection);   Can we do like that and use
 logic:iterator? I tried this 
 and it did'nt work.
 
 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? 
 
 ex:
 
 FileForm myForm = (FileForm) form;
 
 for(int i=0;i=list.size();i++) {
 
 myForm.setXXXElement()
 
 }
 
 Any insights??
 
 
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Struts-logic%3Aiterate-does-not-recognize-the-collection.-tp20385273p20385617.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



Re: Struts logic:iterate does not recognize the collection.

2008-11-07 Thread Dave Newton
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts logic:iterate does not recognize the collection.

2008-11-07 Thread SanJ.SANJAY



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

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



Re: Struts logic:iterate does not recognize the collection.

2008-11-07 Thread Dave Newton
--- On Fri, 11/7/08, SanJ.SANJAY wrote:
 [...] 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 

Such information is useful; I don't recall you mentioning that before.

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

See [1] (or your appropriate version), which states:

id: The name of a page scope JSP bean that will contain the current element of 
the collection on each iteration, if it is not null.

name: The name of the JSP bean containing the collection to be iterated (if 
property is not specified) [...]

Name is the collection. id will be set to each element of the collection.

 what should be the id here if name=xxCollection 
 
 logic:iterate id=?? name=xxCollection
bean:write name=xxCollection /
 /logic:iterate

logic:iterate id=foo name=xxCollection
  bean:write name=foo /
/logic:iterate

But this isn't the issue.

It could just be that I'm completely mis-remembering how logic:iterate... 
works, because I don't see anything particularly wrong. You're including the 
taglib directives, right?

Dave

[1] 1.x logic:iterate... docs:
http://struts.apache.org/1.x/struts-taglib/tlddoc/logic/iterate.html


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