Tim Cross wrote:

Hail gurus, especially Robert Taylor at mulework.com, who,
in spite of his claims not to be a guru, set me right on
my last easy beginner question (as did my friend and former
colleague Ciaran Kenny back in Boulder - the same answer
came in from both gurus within an hour of each other).

Here's this week's abuse of this valuable resource:

There's a database back there somewhere, and it stores
autogenerated primary keys and FSK ratings (little bitty
strings representing ratings for stuff shown in movie
theatres, the German equiv to "G", "PG-13", "R" etc.,
for my fellow Yanks at home and abroad). These FSK ratings
get attached to chunks of content our system keeps track
of. There's an FskRatingAction that populates a LabelValueBean
with the DB ids as values, and the little strings as labels.
Works great for adding and editing stuff that has an FSK rating,
e.g.,

Format: <html:text property="format"/><BR>
FSK Rating: <html:select property="fskRating">
<html:options collection="fskRatingOptionBean" property="value" labelProperty="label"/>
</html:select><BR>
Play Length: <html:text property="playLength"/><BR>


What I'm trying to figure out is this: When I'm trying to display
a bunch of things that have FSK ratings, is there some combination
of logic and bean tags that will allow me to pull in the FSK rating
to the display, i.e., replacing

<td><bean:write name="collectionElement" property="format"/></td>
<td><bean:write name="collectionElement" property="fskRating"/></td>
<td><bean:write name="collectionElement" property="playLength"/></td>

which displays the (not particularly human-useful) Id, with

<td><bean:write name="collectionElement" property="format"/></td>
<td><whatever:whatever bean="fskRatingOptionBean"
whatever="getLabelForValueThatComesFromCollElt"
/></td>
<td><bean:write name="collectionElement" property="playLength"/></td>



I am not sure if I am following your question correctly. But, if "collectionElement" above refers to a "movie bean" that has another bean as the fskRating field, and you need to display a property of *that* bean, you can use the JSTL-like expression language tags (the "bean-el" tags rather than the "bean" tags, the "html-el" tags rather than the "html tags", support this language), to reach the nested property you are after, in this manner:


(I haven't done this exactly -- I usally use the JSTL tags c:forEach c:out instead of the Struts tags -- but I think it should work):

<bean-el:write name="collectionElement" property="${fskRating.label}"/>

Where the current "movie bean" being iterated has methods getFskRating and setFskRating, and the bean returned by the getFskRating method in turn has methods getLabel and setLabel.

Sorry if this is not what you meant,
Erik


Or do I need to set up a separate method in the FskRatingAction to
create a per-row bean that I can pull in with bean:include? Seems
kind of performance-ugly, if so, and much cooler to keep it in
the .jsp file.

Any tips, like last time and always, hugely appreciated.

Tim

[EMAIL PROTECTED]
www.cinedavis.com
Dresden, Germany





---------------------------------------------------------------------
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]



Reply via email to