>>>>> "Vikram" == Vikram Goyal <[EMAIL PROTECTED]> 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 scope.

    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 
value='<bean:write
    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, a
direct translation of your code would look something like the following (with
some renaming):

 <logic:iterate id="country" name="countryCollection">
  <logic:equal name="country" property="value" value="${user.country}">
   <bean:write name="country" property="label" />
  </logic:equal>
 </logic:iterate>

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
[EMAIL PROTECTED]   ; SCJP



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to