Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Olexiy Prokhorenko
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Karl Beowulph
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic