You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Patrick J. Nolan, Jr." <pa...@comcast.net> on 2004/02/10 04:53:07 UTC
Re: Setter on Property (of type Map) Not Getting Called After Form Submit
Joe, I moved the getter and setter code from the POJO to the ActionForm that is linked to the Action (like you mentioned). I am still coming across the problem where the getter is being called, but the setter is not.
public class UserOperationForm extends ActionForm {
public Object getGroupMappedByCategoryId(String key) {
return configurableCategoryGroup.get(key);
}
public void setGroupMappedByCategoryId(String key, Object value) {
configurableCategoryGroup.put(key, value);
}
[...]
}
Any ideas?
Date: Sun, 8 Feb 2004 20:37:56 -0600
From: Joe Germuska <Jo...@Germuska.com>
Subject: Report4Format: Setter on Property (of type Map) Not Getting Called After For
Content-Type: text/plain; charset="us-ascii" ; format="flowed"
At 7:00 PM -0500 2/8/04, Patrick J. Nolan, Jr. wrote:
>The bean that I am working with is NOT an ActionForm - just a POJO -
>I don't think this should matter. I see that the "getter" method is
>getting called correctly by checking my System.out statements.
>However, when I submit the form, the "setter" method does not
>execute. I get no error message. Any ideas?
The only bean population Struts does is upon the the ActionForm
object linked to the request action (via the action-mapping 'name'
attribute).
It would be possible to use Commons BeanUtils and
request.getParameterMap() to achieve what you want, but you'd need to
write your own code to do it. Since ActionForm is a class, not an
interface, there's no way in the current Struts framework to have
Struts automatically populate a non-ActionForm bean.
Using the "name" attribute on an html:* tag is purely for populating
the contents of the form element on display; it has nothing to do
with the processing of the request.
Hope this helps.