Is this something that might be handled by a "normal" mapped property with an
additional property for getting the names of all the dynamic fields?

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

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

public Set getDynamicFieldNames() {
  return this.map.keySet();
}

But your JSP doesn't know the field names ahead of time, so it can't "ask" for
them by name, right? So maybe something like this would work:

<logic:iterate id="fieldName" name="theForm" property"dynamicFieldNames">
  <html:text property='<%= "dynamicField(" + fieldName + ")" %>'/>
</logic:iterate>

Quoting Andrew Hill <[EMAIL PROTECTED]>:

> Cool.
> 
> So if I wanted an ActionForm but the fieldname (or some of them) on it were
> determined only at runtime I could simply make all the 'runtime' fields be
> nested properties of that ActionForm property that had the Map?
> 
> <input name="bob.anything"...
> 
> public void setBob(Map bob)...
> public Map getBob()....
> 
> 
> String anything = form.getBob().get("anything");
> 
> 
> I presume id have to instantiate the Map myself before the form was
> populated though?
> 
> 
> -----Original Message-----
> From: Gemes Tibor [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, 18 June 2003 20:11
> To: Struts Users Mailing List
> Subject: Re: [BeanUtils] Map can or not?
> 
> 
> Andrew Hill �rta:
> 
> >Are PropertyUtils.populate() and getProperty() (etc...) smart enough to
> work
> >with a Map instead of a bean and use the property name as a key into it?
> >
> >
> yes

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

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

Reply via email to