Yes the name is important, but I have to change my previous statements a
little.
Using the one from online doc
public FooForm extends ActionForm {
private final Map values = new HashMap();
public void setValue(String key, Object value) {
values.put(key, value);
}
public Object getValue(String key) {
return values.get(key);
}
}
<html:text property="value(foo)"/>The key of name matching is
property="value(foo)" will trigger invocation of setValue(foo, ) and
getValue(foo)The name matching pattern is property="xxx(key)" matches
function setXxx() getXxx()
The example you give is ActionForm to change java beans.
But set/get values from type Map doesn't fit into the bean coding
convention. That's where map backed ActionForm come into play in struts1.1
----- Original Message -----
From: "Ray Madigan" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, June 06, 2003 11:54 AM
Subject: RE: Action Form: HashMap
> Thanks for your response. It still doesn't work. I looked at the page
> you refered me to and the HashMap is names values and the getter/setter's
> are named getValue, and setValue. Is the s at the end of the map name
> important.
>
> I changed my form/jsp to work with an element of a known name.
>
> in the form
> private String foo = null;
>
> public String getFoo ( ) {
> return foo;
> }
>
> public void setFoo ( String foo ) {
> this.foo = foo;
> }
>
> and the input tag becomes
>
> <html-el:text property='${element.element}'
> value='${element.value}'/>
>
> And it works like a champ. Is there anything else I have to do
> to make the HashMap work? Like use a different Base Form class?
>
> This seems easy enough? I'm losing my mind!
>
> -----Original Message-----
> From: Zhu He [mailto:[EMAIL PROTECTED]
> Sent: Friday, June 06, 2003 8:13 AM
> To: Struts Users Mailing List
> Subject: Re: Action Form: HashMap
>
>
> In your jsp page, you have to specify your input as
> <html:text property="xxx(key)"/>
> where xxx maps to the map name.
> see
>
http://jakarta.apache.org/struts/userGuide/building_controller.html#map_acti
> on_form_classes
> ----- Original Message -----
> From: "Ray Madigan" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Friday, June 06, 2003 10:23 AM
> Subject: RE: Action Form: HashMap
>
>
> > I tried this and it also didn't work. The get and set methods do not
> > call the HashMap directly, cause a HashMap uses get and put.
> >
> > The geters and setters that I supply are the interface to the HashMap,
> > and in this case could be a simple Properties class, if the result
> > is a set of strings? Is this correct, or am i confused?
> >
> > I appreciate your help!
> >
> > -----Original Message-----
> > From: Zhu He [mailto:[EMAIL PROTECTED]
> > Sent: Friday, June 06, 2003 7:04 AM
> > To: Struts Users Mailing List
> > Subject: Re: Action Form: HashMap
> >
> >
> > if you are using map backed actionForm, make sure getXXX() setXXX()
where
> > XXX matches the name of the map.
> > In you case function names should be getMap() setMap()
> > ----- Original Message -----
> > From: "Ray Madigan" <[EMAIL PROTECTED]>
> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > Sent: Friday, June 06, 2003 9:37 AM
> > Subject: RE: Action Form: HashMap
> >
> >
> > > OK, I made the following changes, and it didn't do what I expected.
> > > HELP!
> > >
> > > I added to the ActionForm:
> > >
> > > /**
> > > * The form HashMap
> > > */
> > > private HashMap map = new HashMap ( );
> > >
> > > public Object getStringMapped ( String key ) {
> > > return map.get ( key );
> > > }
> > >
> > > public void setStringMapped ( String key, String value ) {
> > > map.put ( key, value );
> > > }
> > >
> > > I modified the jsp as:
> > > <html:form action='Foo.do'>
> > >
> > > <c:forEach var='element' items='${elements}' >
> > > <html-el:text property='stringMapped ( ${element.element} )'
> > > value='${element.value}'/>
> > > </c:forEach>
> > >
> > > ...
> > >
> > > </thml:form>
> > >
> > > When I look at the form in my DispatchAction map is always empty.
> > >
> > > Any help would be appreciated!
> > >
> > > -----Original Message-----
> > > From: David Graham [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, June 05, 2003 11:13 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: Action Form: HashMap
> > >
> > >
> > > Read the mapped properties section here:
> > > http://jakarta.apache.org/struts/faqs/indexedprops.html
> > >
> > > David
> > >
> > >
> > > >From: "Ray Madigan" <[EMAIL PROTECTED]>
> > > >Reply-To: "Struts Users Mailing List"
<[EMAIL PROTECTED]>
> > > >To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > > >Subject: Action Form: HashMap
> > > >Date: Thu, 5 Jun 2003 11:00:12 -0700
> > > >
> > > >I have a form that has elements that I do not know the names of ahead
> > > >of time.
> > > >
> > > >I want to have struts scrape the form into a map so the key is the
name
> > > >of the element and the value is the value of the element when it was
> > > >submitted.
> > > >
> > > >I looked for an action form that acted like this. Has anyone done it
> > > >before, or is there a better way?
> > > >
> > > >
> > > >
> > > >---------------------------------------------------------------------
> > > >To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > >For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > >
> > > _________________________________________________________________
> > > Tired of spam? Get advanced junk mail protection with MSN 8.
> > > http://join.msn.com/?page=features/junkmail
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]