You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tim Cross <tc...@cinedavis.com> on 2004/09/06 19:34:07 UTC

another easy (I hope) beginner question

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>

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

tcross@cineNOSPAMdavis.com
www.cinedavis.com
Dresden, Germany





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


Re: another easy (I hope) beginner question

Posted by Vic <vi...@portalvu.com>.
Not sure what your are trying to do or what your question is, can you 
pleas exaplin again?

(my guess is taht jstl and a cached dao that outputs a collection is 
going to be the answer, but I am not sure of the question or the 
perofrmance issue you see)

.V

(Muleworks looks cool! )

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>
> 
> 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
> 
> tcross@cineNOSPAMdavis.com
> www.cinedavis.com
> Dresden, Germany


-- 
Please post on Rich Internet Applications User Interface (RiA/SoA)
<http://www.portalvu.com>


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


Re: another easy (I hope) beginner question

Posted by Erik Weber <er...@mindspring.com>.

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
>
>tcross@cineNOSPAMdavis.com
>www.cinedavis.com
>Dresden, Germany
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>  
>

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


RE: another easy (I hope) beginner question

Posted by Daniel Perry <d....@netcase.co.uk>.
If i understand your question right, you have a code
collectionElement.fskRating which represents a rating? (ie 1 = "pg-13",
2="G").

I have never done this, but i dont see why you cant just put an array/map of
the full values into the request scope, then use jstl to look it up:
somthing like: ${fullFskRatings[collectionElement.fskRating]} (cant remember
exactly how to do it).

The other method would be to add a "getFullFskRating()" to the
collectionElement bean.

Or write a custom tag that does the conversion, ie: <mytag:fskrating
value="collectionElement.fskRating"/>


Daniel.




> -----Original Message-----
> From: Tim Cross [mailto:tcross@cinedavis.com]
> Sent: 06 September 2004 18:34
> To: user@struts.apache.org
> Subject: another easy (I hope) beginner question
>
>
> 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>
>
> 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
>
> tcross@cineNOSPAMdavis.com
> www.cinedavis.com
> Dresden, Germany
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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