struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <k...@dotech.com>
Subject RE: Map-backed ActionForms with JSTL
Date Wed, 11 Dec 2002 16:59:49 GMT
Assuming you've got something like:

public ProfilePageForm extends ActionForm {
  private final Map map = new HashMap();

  public void setProperty(String key, Object value) {
    map.put(key, value);
  }

  public Object getProperty(String key) {
    return map.get(key);
  }
}

As a standard bean, there really aren't any properties exposed for JSTL to play
with. You'd have to add something like:

public Map getMap() {
  return map;
}

Then you should be able to do:

<c:out value="${profilePage.map.ID}"/>

or:

<c:out value="${profilePage.map['ID']}"/>

Quoting Jarnot Voytek Contr AU HQ/SC <Voytek.Jarnot@MAXWELL.AF.MIL>:

> not a JSTL expert here, but have you tried ${profilePage.property["ID"]}?
> 
> -----Original Message-----
> From: Justin Ashworth [mailto:justin-struts@ashworth.org]
> Sent: Wednesday, December 11, 2002 10:34 AM
> To: Struts Users Mailing List
> Subject: Map-backed ActionForms with JSTL
> 
> 
> Hi,
> 
> Has anyone been able to successfully access properties in a map-backed
> ActionForm with JSTL?  I haven't been able to come up with the expression
> language to retrieve properties out of a Map in my ActionForm.  If this is
> possible, what is the syntax?  I have tried <c:out
> value="${profilePage[property].ID}", but that didn't return anything.  I
> don't get a compilation error - it just returns empty.  profilePage is my
> ActionForm, property is the name of the Map within my form (with the
> appropriate getProperty(String) and setProperty(String, Object) methods),
> and ID is the key within the property Map.
> 
> Once I get this figured out, I'm going to try to replace ID with a constant
> variable defined in some class.  Ideas on that?
> 
> Thanks,
> 
> Justin
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:  
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
> 


-- 
Kris Schneider <mailto:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Mime
View raw message