This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSP and the fly likes JSTL forEach tag in struts problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL forEach tag in struts problem " Watch "JSTL forEach tag in struts problem " New topic
Author

JSTL forEach tag in struts problem

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, i facing a problem in jstl , i using foreach tag to iterate the list ,

it working , but the problem is when i want to put struts checkbox into jstl, it give me error



can i set the value of checkbox as above code ? or what are the correct way to do so ? thank you
Stefan Willi
Ranch Hand

Joined: Mar 11, 2005
Posts: 47
If you get an compile Error, then try



You must not use the c ut tag, you simply can use the EL.

I have not tried this code, but think, this should work.

Stefan
[ April 08, 2005: Message edited by: Stefan Willi ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Stefan is correct. You can never use a tag as an attribute to another tag; Struts or otherwise.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15629
    
  15

Originally posted by Bear Bibeault:
Stefan is correct. You can never use a tag as an attribute to another tag; Struts or otherwise.


No?



Customer surveys are for companies who didn't pay proper attention to begin with.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15629
    
  15

Seriously, the ability to place expressions in attributes is dependent on how the tag was defined.

However, the <html:checkbox> tag is a Struts tag and it should be coded according to Struts constraints.

You don't need a <c ut> tag here, because you can use EL and just say:



Note that "bean,myname is incorrect. Use a dot, not a comma, just like in regular Java.

Also, this only works if you include the Struts.el jar!

The normal Struts classes don't support EL.

This question would have been more appropriate for the Struts forum, BTW.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

No?


Clarification:

You can never use a tag as an attribute to another custom tag; Struts or otherwise.

Tim's example shows a custom tag being used as an attribute to an HTML tag, which is, of course, fine and dandy since the HTML tag is merely template text.
[ April 08, 2005: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL forEach tag in struts problem
 
Similar Threads
doubt about storing selected checkboxes in formbean
Is it possible to draw struts-tag in javascript ....?
how to add checkbox html tag?- urgent!
Iteration of List in JSP
JSTL <c:forEach .../> tag not working with collection