struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Quentin.Cope" <>
Subject RE: Dynamic Value for logic equal
Date Mon, 11 Nov 2002 10:49:57 GMT

I needed to do something similar in the current project that I am working on. Not sure if
this is the right answer but searching through the maillist, I convinced myself that the reason
why its not straightforward, is that the designers of struts consider the "view" not to be
the place to be doing this sort of stuff.

I ended up writing an ActionClass, called first, that does a lookup similar to yours, and
puts the required information onto the request/session. My view then just needs to worry about
displaying this information. 



-----Original Message-----
From: Vikram Goyal []
Sent: 10 November 2002 06:49
To: Struts Users Mailing List
Subject: Re: Dynamic Value for logic equal

Thanks David/Edgar,

I have actually done it in a scriptlet, but it is departing from the idea of
keeping JSP's scriptlet free. I am surprised that there is no generic way of
handling this in Struts. I always assumed that it would be till I actually
had to do it !!

The EL approach seems better but how was this tackled before Struts-EL came
into picture? I am guessing the scriptlet way?


----- Original Message -----
From: "David M. Karr" <>
To: <>
Sent: Sunday, November 10, 2002 10:23 AM
Subject: Re: Dynamic Value for logic equal

> >>>>> "Vikram" == Vikram Goyal <> writes:
>     Vikram> When displaying information about a User, I need to display
the Label for a
>     Vikram> Country Code. This should be simple enough. However, the User
bean contains
>     Vikram> only the country code. To get the Country label, I need to
iterate over the
>     Vikram> Country Data static collection, which stores information about
each country
>     Vikram> as a LabelValueBean. This collection is stored in session
>     Vikram> However, the problem is that while inside the logic:iterate
tag, the
>     Vikram> logic:equal tag does not accept dynamic value for the 'value'
attribute. The
>     Vikram> processing should be like this:
>     Vikram> <logic:iterate id="countries" name="countryCollection"
>     Vikram> type="org.apache.struts.util.LabelValueBean">
>     Vikram>     <logic:equal name="countries" property="value"
>     Vikram> value="USER.GETCOUNTRYCODE">
>     Vikram>         <bean:write name="countries" property="label" />
>     Vikram>     </logic:equal>
>     Vikram> </logic:iterate>
>     Vikram> The USER.GETCOUNTRYCODE is the problem part. I have tried
>     Vikram> name="user" property="country"/>'. This does not work, as it
seems that it
>     Vikram> is parsed as is by the compiler. I also tried using
bean:define for the
>     Vikram> country code and then passing that in but that fails as well.
>     Vikram> I ended up writing a scriptlet around it to solve the problem,
but am not
>     Vikram> convinced that it is the best way to go about it.
> Your alternatives are to use a scriptlet or to use the Struts-EL library
in the
> nightly build (as described in another response to this).  With Struts-EL,
> direct translation of your code would look something like the following
> some renaming):
>  <logic:iterate id="country" name="countryCollection">
>   <logic:equal name="country" property="value" value="${}">
>    <bean:write name="country" property="label" />
>   </logic:equal>
>  </logic:iterate>
> --
> ===================================================================
> David M. Karr          ; Java/J2EE/XML/Unix/C++
>   ; SCJP
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

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

View raw message