> > Dave Newton wrote:
> > > <tr class="<s:property value="%{getStatus(deviceID)}"/>">
> > 
> > Minor addendum:
> > 
> > IMO when iterating over a collection of model objects a 
> status lookup 
> > like this would be a matter of querying the device, rather than 
> > providing a lookup based on the device ID.
> > 
> > If device statuses need to be mapped to CSS classnames I'd pass the 
> > device itself to a utility translation method rather than 
> forcing the 
> > translator to look up the device.
> > 
> > This moves the generation of view-level data out of the 
> device model, 
> > eliminates the need to look up a device that already exists as a 
> > model, and provides a measure of type safety (Java's OOP, 
> after all).
> > 
> > The utility class could be used as shown, or in a JSP-based custom 
> > tag, which can significantly clean up the view layer 
> depending on your 
> > requirements and/or implementation.
> > 
> > Dave
> 
> I would like to do that, but if I have a Device object on the 
> top of the value stack (or perhaps somewhere near the top), 
> how would I grab that and pass it to the function? I just 
> tried this and it didn't work:
> 
> <tr class="<s:property value="%{getStatus([0])}" />">
> 
> (after modifying the function to take a Device instead of an 
> ID number).

Nevermind, I figured it out:

<s:iterator value="devices" var="dev">
        <tr class="<s:property value="%{getStatus(#dev)}" />">
        ...
        </tr>
</s:iterator>

Thanks for your suggestion!
~Jonathan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to