One last thing :
Even if everything works, I still get a stacktrace when I submit the
form to save my object.
I think that the params interceptor tries to set the properties of the
object "jspProfile" I have in my form (with <s:checkbox
name="jspProfile.recpCheckErrorCount"/> for example), before the
prepare interceptor initialize that object.
Even if I initialize the object in the action's constructor, I get the stack.
2010-05-10 12:34:12,062 [http-8080-Processor24] WARN
com.opensymphony.xwork2.ognl.OgnlValueStack - Error setting value
ognl.OgnlException: target is null for setProperty(null,
"recpCheckErrorCount", [Ljava.lang.String;@62812d)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651)
at ognl.ASTProperty.setValueBody(ASTProperty.java:101)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
at ognl.SimpleNode.setValue(SimpleNode.java:246)
at ognl.ASTChain.setValueBody(ASTChain.java:172)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
at ognl.SimpleNode.setValue(SimpleNode.java:246)
at ognl.Ognl.setValue(Ognl.java:476)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192)
at
com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:155)
at
com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:143)
at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:273)
at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:187)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
...
2010/5/10 Thomas Lulé <[email protected]>:
> It works.
>
> Thanks a lot Lukasz and Alex.
>
> 2010/5/10 Alex Rodriguez Lopez <[email protected]>:
>> Hi Thomas,
>>
>> use the paramsPrepareParams interceptor stack (or change yours), from
>> struts-default.xml:
>>
>> <!-- An example of the paramsPrepareParams trick. This stack
>> is exactly the same as the defaultStack, except that it
>> includes one extra interceptor before the prepare
>> interceptor:
>> the params interceptor.
>>
>> This is useful for when you wish to apply parameters
>> directly
>> to an object that you wish to load externally (such as a DAO
>> or database or service layer), but can't load that object
>> until at least the ID parameter has been loaded. By loading
>> the parameters twice, you can retrieve the object in the
>> prepare() method, allowing the second params interceptor to
>> apply the values on the object. -->
>> <interceptor-stack name="paramsPrepareParamsStack">
>> ...
>>
>> I think this accomplishes what you are looking for (of course you need
>> setters for the parameters that you want params interceptor to have ready
>> for you by the time the prepare() method is called).
>>
>> Em 10-05-2010 09:39, Thomas Lulé escreveu:
>>>
>>> That interceptor looks great, but is there any way to access request
>>> parameters in the prepare() method ?
>>>
>>> The http request provides an "archiveProfileId" parameter and I use
>>> that parameter to load my object "archiveProfile".
>>>
>>> 2010/5/10 Lukasz Lenart<[email protected]>:
>>>>
>>>> Use Preparable interface instead
>>>>
>>>> http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/Preparable.html
>>>>
>>>>
>>>> Regards
>>>> --
>>>> Łukasz
>>>> http://www.lenart.org.pl/
>>>> Kapituła Javarsovia 2010
>>>> http://javarsovia.pl
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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]