Erik Weber wrote:
I assume by "bean" you mean form bean (ActionForm). I sometimes carry
non-text attributes in form beans, but that data doesn't represent
form inputs (which is really why a form bean exists) but maybe
metadata associated with a form or with a form input. Typically those
attributes will be collection fields (such as Vectors) that I will
iterate using either c:forEach (or logic:iterate). Within the
iteration I'll use c:out (or bean:write) to render properties of the
objects in the collection. So, yes, it can be done. Using these fields
in cooperation with a session-scoped form bean can really help when
you've got a validated form that has a ton of metadata you need to
display. I'm not familiar with any tags that operate on Enumerations,
however.
To operate on the data, I use something like this:
<c:set var="details" scope="page" value="${myForm.someCollectionField}"/>
and
<c:forEach items="${details}" var="current">
. . .
<c:out value="${current.someProperty}"/>
. . .
</c:forEach>
or simply
<c:forEach items="${myForm.someCollectionField}" var="current"/>
Heh. A c:forEach with no body wouldn't do much good!
Correction:
<c:forEach items="${myForm.someCollectionField}" var="current">
. . .
</c:forEach>
Erik
if you don't need to refer to the collection field anywhere but in
your loop.
"myForm" would be the declared name of your form bean in
struts-config.xml.
Erik
Scott Purcell wrote:
Hello,
I am trying to learn struts adn playing with some test code. I have a
bean that returns an Enumeration for my view. but I cannot figure out
how to get the data.
The two ways so far, have been to use the html:text and bean:write
syntax.
Can I receive Objects other than strings back from a bean that is
configured in the 'struts-config.xml' file? Any links to figure this
out?
I am able to get normal strings back from the bean by using the
following two techniques.
<html:text property="name" />
<bean:write name="menubean" property="something" />
Thanks,
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]