struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark S Petrovic <>
Subject Re: Newbie help with Struts idiom: functional if/else tags
Date Tue, 15 Nov 2005 13:57:54 GMT
Thank you for the reply.

1.  I want to say yes, Feature is a proper JavaBean, with essentials

public class Feature {
  private boolean premium;
  public void setPremium(boolean b) { premium = b; }
  public boolean isPremium()        { return premium; }

and no overloaded methods.

"features" is populated thusly

ArrayList features = new ArrayList();
Feature f = new Feature();
f.setPremium(true); // e.g.

and finally, in the Action.execute() method of the associated Struts

            request.setAttribute("features", features);
            return (mapping.findForward(target));

where the request.setAttribute() is the share-with-JSP-view technique
used by the Struts book I'm reading.

2.  Failing to get the <c:choose> to work within <logic:iterate> in
#1 above, I also tried a different tack:  using <c:forEach> instead of
<logic:iterate> to cycle through the list elements that <logic:iterate>
formerly treated:

For the same ArrayList "features", containing instances of bean "Feature"
as above and set with the same Struts Action.execute via

            request.setAttribute("features", features);

I attempt

<c:forEach var="feature" items="${requestScope.features}">
            <c:when test="${feature.premium == true}">
         <c:out value="${feature.premium}"/>

which isn't even iterating over the list items.  E.g, I get one line of
html output for the <c:out value="${feature.premium}"/> tag, containing
the string literal '${feature.premium}' in quotes - as if expansion of
${feature.premium} is not taking place.

I know the issues I'm raising are very elementary, but I hope they help
someone else in the process.


On 14Nov, Wendy Smoak wrote:
> On 11/14/05, Mark S Petrovic <> wrote:
> >    <c:when test="${feature.premium == true}">
> Should just be  <c:when test="${feature.premium}">
> Is 'feature' a proper JavaBean?  The types for get(is)/set methods
> match, no overloaded set methods, etc?
> --
> Wendy
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Mark Petrovic
Pasadena, CA  USA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message