wood burning stoves 2.0*
The moose likes JSP and the fly likes JSTL Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL Question" Watch "JSTL Question" New topic
Author

JSTL Question

Tom Henricksen
Ranch Hand

Joined: Mar 23, 2004
Posts: 136

I am doing a for each in JSTL on a collection(List).



How do I add something to to the object dynamically? Say I have a trait attribute and need to add maybe 2 or 6 to my hybrid object? So I would have a List of traits on my Hybrid. Can I do nested forEach like



Thanks,
Tom
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
I believe this can only be used to access/render information. And, you can not use it to update. I am sure someone will probably give a better explanation.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Originally posted by Bosun Bello:
you can not use it to update.


Sure you can. That's what <c:set> is for.

But... I'm very confused by the original question. You state that you want to "add" something, then give an example regarding nested looping. So I really have no idea what it is you are trying to accomplish.

If what you are asking is: how to loop on a nested collection (in other words, if traits is a collection that is a property of hybrid) then something like the following would suffice:



If your questions is something other than that, you're going to need to make what you are trying to do a bit clearer.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tom Henricksen
Ranch Hand

Joined: Mar 23, 2004
Posts: 136

That is what I am trying to do Bear. I appreciate everyone's help. I apologize for being unclear.
Thanks,
Tom
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

If you are going to be processing incoming parameters, and modifying your datastructures,


I think he made it clear in his last post that that's not what he's trying to do. He only wanted to nest the forEach loops and was confused as t o how to reference the nested element.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
>I think he made it clear in his last post that that's not what he's trying to do
good point, my bad. (deleted post so as not to confuse anybody else)
 
jQuery in Action, 2nd edition
 
subject: JSTL Question
 
Similar Threads
Iteration of List in JSP
JSTL and collections
Keep HTML tag in String
JSTL nested Collection Exception
Websphere 6 not recognizing c:forEach