*
The moose likes Struts and the fly likes Small problem while iterating over Collection with logic:iterate... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Small problem while iterating over Collection with logic:iterate..." Watch "Small problem while iterating over Collection with logic:iterate..." New topic
Author

Small problem while iterating over Collection with logic:iterate...

Olexiy Prokhorenko
Ranch Hand

Joined: Jul 11, 2004
Posts: 97
Hi guys,


Actually, I didn't touch Struts for a pretty long period of time as a developer, so I forgot almost everything. Too many frameworks at the moment! :-)

So, my question probably will be pretty dumb. Please, help if you know solution ;-)

I have bean (value object, pojo, call it whatever you want).





And I have a List (ArrayList) of these beans.
I am putting it into request scope. Besides, in request scope I have few variables which are called this way:


data12
data105
dataNNN


where is NNN is 'id' of some MyBeans' from List

I am iterating this way:


The problem is that I need to check if 'dataNNN' for each bean from List is equal to bean's field somedata, and do something about that.

Unfortunatelly, if I am doing like this:



This gives me an error. I guess it something about nested tags, but I am not sure which are allowed and how can I do above mentioned thing other way.


Any help? :-)

Thanks!


<a href="http://www.BossTalks.com" target="_blank" rel="nofollow">http://www.BossTalks.com</a><br />Free advices and help for entrepreneurs: from Idea to IPO<br />Software and IT Project Management forum
Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
Struts doesn't really support nesting tags very well.

I think a quick and dirty way to do this would be to make the various beans into JSP beans and then use java code (<% ... %> to compare them.
Olexiy Prokhorenko
Ranch Hand

Joined: Jul 11, 2004
Posts: 97
This is exactly what I found. Stupid problems with nested tags...

Okay. Do you know some more pleasant and nice-looking way out? :-)
Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
Unfortunetly not.

The only options I'm aware of is the creation of JSP beans and using them for your logic and so forth (the method I use), or creating custom tags.

The second one may look nicer on the JSP page, but the tag Java code itself is likely to be pretty ugly (especially if you're putting HTML tags in it) and take more time to write.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Small problem while iterating over Collection with logic:iterate...
 
Similar Threads
logic:iterate hashmap with key of hashmap
Regarding Logic iterate
logic:match , logic:notEqual not working
create select list from lag library without using struts
how to solve No collection found.