Bouvet Konsulent wrote:
hello,
I have a Struts form-bean which contains a HashMap. The keys of this
hashmap is an object of type GeSectionComponent. In my jsp, I iterate
over a collection of these GeSectionComponents. For each iteration, I
would like to lookup in the HashMap to retrieve the value corresponding
to the GeSectionComponent. Does anyone have an idea of how to do this?

I have bee trying to use the JSTL c:set-tag to be able to use the
GeSectionComponent as a variable in my jsp, but I can't seem to get it
to work. Absolutely non-working code looks something like:

<logic:iterate id="geSectionComponent" name="initialReportForm"
property="geSectionComponents">
        <c:set var="comp" value="????"/>
        <jsp:useBean id="comp"
type="com.acme.ge.generated.GeSectionComponent" />
        <% ????.getPowerLimits(comp); %>
</logic:iterate>

My form contains a getter for the HashMap:

    public HashMap getPowerLimits() {
        return powerLimits;
    }

any help would be appreciated!

Remember that a Map is a Collection of Map.Entry objects, so when you iterate a map property you're getting instances of those. You access the actual key and value of the entry via its 'key' and 'value' properties.

Your sample JSP and Java code don't seem to match up (you have a getPowerLimits() method in the form bean but you're using a property named geSectionComponents to access the collection in your logic:iterate tag). What I *think you want is this:

  <logic:iterate id="pl" name="initialReportForm"
      property="powerLimits">
    <c:set var="comp" value="${pl.key}"/>
    <c:set var="limit" value="${pl.value}"/>
    ...
  </logic:iterate>

That will fetch the Map from the powerLimits property of the form and, for each entry in the map, set 'comp' to the GeSectionComponent (key) and 'limit' to whatever is in the map under that key.

If I've mis-understood what you're trying to achieve, try posting the relevant code and an example of the HTML you want to generate.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to