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.

Mark

-----Original Message-----
From: Gary Affonso [mailto:[EMAIL PROTECTED] 
Sent: 19 November 2007 16:34
To: Struts Users Mailing List
Subject: Re: [s2] Prepare and Parameter Interceptors

You've got the interceptor setup order correct.  You haven't really 
provided enough info to really identify another other problems (we'd 
need to see the form fields, the action, and the object being exposed 
and hydrated in the action.)

But here are some things you can try...

1) turn on debugging for *both* struts and xwork...

<logger name="org.apache.struts2"><level value="DEBUG"/></logger>
<logger name="com.opensymphony.xwork2"><level value="DEBUG"/></logger>

... and then submit your form to your action.  This will give you 
detailed info as s2/xwork attempt to find and set values on your
properties.

2) Be sure that your action has provided a setter for the recently 
hydrated object.

3) Be sure your form fields reference the hydrated object and its 
properties with a valid OGNL expression...

<input type="hidden" name="myObject.myProperty" value="foo" />

(note the "myObject." prefix)

4) An alternative to steps #2 and #3 is ModelDriven
A waste of effort, IMO, but that's another way you can expose your 
recently hydrated object to the form.  You would not need the 
"myObject." prefix on your fieldnames or a setter in the Action for that

object if you use ModelDriven.

---

If none of that does the trick, you'll need to provide more detail, I'm 
out of guesses. :-)

- Gary

Mark Steyn wrote:
> I'm trying to use the Prepare interceptor in conjunction with the
> Parameters interceptor to create objects from persistent storage
before
> Struts 2 sets their properties based on values posted from a form, as
> suggested in
> http://struts.apache.org/2.0.11/docs/prepare-interceptor.html
> 
>  
> 
> My understanding of the steps involved is as follows:
> 
>  
> 
> 1. The ParametersInterceptor creates objects based on the values
posted
> to the form.
> 
> 2. The prepare method called by the PrepareInterceptor replaces those
> objects with objects instantiated from a database.
> 
> 3. The ParametersInterceptor is called again, updating the objects
> constructed from the database with the values posted in the form.
> 
>  
> 
> The first 2 steps work fine, but not the 3rd.
> 
>  
> 
> The Parameters interceptor is definitely being called before and after
> the Prepare interceptor, but the second call doesn't set the
properties
> of the objects created in step 2.
> 
>  
> 
> The intercept stack for the my is:
> 
>  
> 
>             <interceptor-ref name="fileUpload"/>
> 
>             <interceptor-ref name="params">
> 
>                 <param name="ordered">true</param>
> 
>             </interceptor-ref>
> 
>             <interceptor-ref name="database"/>
> 
>             <interceptor-ref name="prepare"/>  
> 
>             <interceptor-ref name="params">
> 
>                 <param name="ordered">true</param>
> 
>             </interceptor-ref>
> 
>  
> 
> Am I overlooking something, or is there something else I need to do?
> 
>  
> 
> Thanks,
> 
> Mark
> 
> 


---------------------------------------------------------------------
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]

Reply via email to