Unfortunately, the Struts documentation isn't much help this department
(unless I'm missing something), except that I think it tells you which
Struts tags *don't* support the EL.
But this page ought to help:
http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSTL4.html
There is also a blurb about using the EL in the Struts FAQ entry on
indexed properties.
If you look in your Struts distribution, you'll see the EL-related stuff
in the contrib directory. You use the Struts EL tags the same way as you
use the regular Struts tags (except you use the EL instead of using the
old-fashioned runtime expression language).
For example:
bean-el:size collection=${someBean.someCollection} id=numItems/
This Struts tag assumes there is a bean called someBean which exposes
a collection via the no-arg method getSomeCollection. It makes the
size of the collection available via the numItems variable, which can
be used subsequently like this, for example:
c:when test=${numItems 0}/
There may be more efficient ways to do the same thing, but this gives
you an example of a Struts tag and a JSTL tag that each use the EL.
I recommend the book JSTL by Sue Spielman (Morgan Kaufmann,
0-12-656755-7). It's only $20 new and worth it. It discusses the JSTL
tags and the EL in depth and is based on example. I have found that
using a combination of the Struts tags and JSTL tags made my JSPs the
nicest, but I think there's not much the Struts tags do that the JSTL
tags can't do.
Hope that helps,
Erik
Vijay Vishvas Dharap wrote:
Can you tell how to use EL code.
Am kind of newbie to Struts and and not much aware of EL tags.
But my containier is only JSP 1.2
Also I am using struts 1.1
-Original Message-
From: Rick Reumann [mailto:[EMAIL PROTECTED]
Sent: Saturday, October 16, 2004 7:57 PM
To: Struts Users Mailing List
Subject: Re: logic:iterate and table display
Vijay Vishvas Dharap wrote the following on 10/15/2004 9:41 PM:
Hi all,
I have following scenario..
I have FormBean which has getter and setter for my VO object
In VO I have a list of another VO.
Now on this form I want to display the contents of the list using
logic.iterate tags.
I will make matter simpler saying...
aFormBean has aVO which as list of bVO. bVO has attributes like xAttr,
yAttr, zAttr.
now aForm should show on the page table where contents of list of bVO
will be giving one one row of the table.
You can do this with struts logic and bean:write,I'm used to JSTL so
here it is...
c:forEach items=${yourFormName.aVo.bVOlist} var=bVOitem
c:out value='${bVOitem.xAttr}'/
%-- or JSP2.0 just ${bVOitem.xAttr} --%
c:out value='${bVOitem.yAttr}'/
/c:forEach
with logic iterate within your html:form tags (I 'think' this is
right?)
//use the EL struts tags if not using JSP2.0 Container
logic:iterate property=aVo.bVOlist id=bVOitem
bean:write name=bVOitem property=xAttr/
bean:write name=bVOitem property=yAttr/
/logic:iterate
Obviously you would surround the above with table tags etc. Or you could
also use the display tag (search google or archives) that will do this
for you.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]