struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Hill" <andrew.david.h...@gridnode.com>
Subject RE: [BeanUtils] Map can or not?
Date Wed, 18 Jun 2003 13:30:38 GMT
<snip>
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:
</snip>

Nah mate. Not using JSP. In this case Im actually traversing an xhtml DOM
and doing a getProperty() to get values when I encounter input elements
(etc...) based on the name attribute and using the result to set the value
attribute. (or checked attribute or... whatever... for that type of field)

Id quite like the ability to have user defined forms (perhaps I could map
names to xpaths in an xml doc for persistance ... or whatever) where the
user needs merely to upload the xhtml for the form , and perhaps specify
which fields are required etc... and then my app would do the grunt work for
rendering/ populating/ etc....


-----Original Message-----
From: Kris Schneider [mailto:kris@dotech.com]
Sent: Wednesday, 18 June 2003 21:19
To: Struts Users Mailing List; andrew.david.hill@gridnode.com
Subject: RE: [BeanUtils] Map can or not?


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 <andrew.david.hill@gridnode.com>:

> 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:tib@i-trade.hu]
> 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:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>


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


Mime
View raw message