Mark Steyn wrote:
Thanks for your help Gary. I got to the bottom of the problem, or at
least got around it in the end.
After Struts created objects based on the submitted form values, I was
using the ids of those objects to create corresponding objects
instantiated with values from a database. I then used the action's
setters to replace the objects created by Struts. It seems that part
caused the problem. Rather than replacing objects, I copied back the
properties instead and it works.
Good to hear you have it working.
Sounds like you're doing something like this...
Form
----
<input type="hidden" name="myObject.Id" />
<input type="hidden" name="myObject.Name" />
Action
------
private MyObject myObject;
public ... myObject setter ...
public ... myObject getter ...
The first params pass creates one so that it can set the Id (and the
name), you go take that ID go get the real object, replace the one
auto-created (or at least replace it's property values), and then the
2nd params pass sets the values on that newly instantiated object.
That's the workflow you're using, right?
I find that confusing, what I do instead is this...
Form
----
<input type="hidden" name="Id" />
<input type="hidden" name="myObject.Name" />
Action
------
private Long id;
public ... id setter ...
public ... id getter ...
private MyObject myObject;
public ... myObject setter ...
public ... myObject getter ...
That way with the first params pass I'm sucking the ID into a separate
and distinct property on the action (not letting OGNL create an object
and setting the property that way).
Then I take the Id, go get the object, set myObject to that newly
retrieved object and let the 2nd pass inject into it.
I just find *not* using a domain object to suck in all my IDs in the
first pass is a little less confusing. But maybe that's me. You
clearly get the idea of how the params/prapre/params sandwich works,
from there it's just preferences.
- Gary
P.S. As noted in another thread, keep in mind that you can do all of
this without the interceptor sandwich. You can do this with the
conversion portion of the framework, and you can also do this by simply
coding more sophisticated getters/setters. It's really up to you.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]