I don't think this is a bug.

Because the basic idea of WEB app is: everything is passed as String.

Actually, there is a special layer in struts2 for data conversion.
Your action may take int/long/boolean/date or something else as it's
parameters, but all the original request parameters are String, and
they are converted to appropriate data type by struts2 automatically.
See:
http://struts.apache.org/2.2.1/docs/type-conversion.html

So, if param tag convert your parameter into String,
I don't think this acting is incorrect, because the Action which
receive this parameter should take the responsibility to convert it
from String to something it need.

In your case, your are calling an action from some action else. But
think about calling it from the client side (for example: in browser),
how could you pass an object instance as parameter? The only thing you
can pass is String.

So, my suggestion is:

(1)Don't use an object instance as the parameter.
Use the object id (can be int, string, and so on) instead.
And in the action, load the object by id
If you worry about the performance issue caused by object loading, you
can use cache.


OR

(2)If your action will be accessed from other actions only, but never
be called from the client side.
Then you can delete the parameter from the action.
Use request (or session) attribute instead.
Before calling the action, put the object into request (or session) attribute.
And in the action, load it from request (or session) attribute.





2010/11/17 Raj Nagappan <r...@velocitylabs.com>:
> I did some experimenting with this by removing the lazy load and putting the
> actual object directly on a property in the action class. This had no
> effect.
>
> So then I created a catch-all method setKeywordList(Object obj) to see what
> was being passed in. The actual data being passed in is a single element
> String array. The only element in the array is a string
> "keywordl...@1f75664" ie. the Struts param tag is calling toString() on the
> object and passing the resulting string inside an array to the action class.
>
> I would say this is a regression bug from 2.0.x, yes?
>
> Raj.
>
>
> On 16/11/2010 9:18 PM, Raj Nagappan wrote:
>>
>> Hi,
>>
>> The parameter is definitely an object, if I replace the JSP below with
>>
>> <h1><s:property value="photoSet.keywordListLazyLoad"/></h1>
>> <h1><s:property value="photoSet.keywordListLazyLoad.id"/></h1>
>>
>> I get keywordl...@3bcdf1, 15
>>
>> which is correct. Furthermore if I add a setKeywordList(String[] param)
>> method or setKeywordList(String param) method into the action class, it
>> never invokes those new methods but still throws exactly the same exception.
>>
>> The only other thing I can think of is that it's trying to set the cglib
>> proxy object on the action class and is complaining about that. We are using
>> cglib-nodep-2.2 to lazy load the KeywordList, and it worked perfectly fine
>> in Struts 2.0.
>>
>> (Sorry if this appears multiple times, I keep getting a spam rejection
>> notice.)
>>
>> Raj.
>>
>> On 6:59 AM, Li Ying wrote:
>>>
>>> "[Ljava.lang.String;" means a String array.
>>>
>>> Looks like you are trying to copy a List from one action to another.
>>>
>>> By somehow, struts2 is looking for a set method which take a String
>>> array as it's parameter.
>>>
>>>
>>>
>>> 2010/11/15 Raj Nagappan<r...@velocitylabs.com>:
>>>>
>>>> Hi, we recently upgraded from Struts 2.0.14 to 2.2.1 and I notice that
>>>>
>>>> the following JSP code to inject an object property from one action into
>>>> another action has stopped working:
>>>>
>>>> <s:if test=hotoSet.keywordListLazyLoad != null">
>>>> <s:action namespace=search" name="KeywordList" executeResult="true"
>>>> ignoreContextParams=rue">
>>>> <s:param name=eywordList" value="photoSet.keywordListLazyLoad"/>
>>>> </s:action>
>>>> </s:if>
>>>>
>>>> So it checks that the object is not null and then tries to set it on the
>>>> parameter "keywordList". This worked perfectly fine in 2.0.x, but in 2.2
>>>> on the server side we get:
>>>>
>>>> java.lang.NoSuchMethodException:
>>>> KeywordListAction.setKeywordList([Ljava.lang.String;)
>>>> Â  Â at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1226)
>>>> Â  Â at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474)
>>>> Â  Â at
>>>>
>>>> ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
>>>> Â  Â at
>>>> ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
>>>>
>>>> And the resulting error displayed on the web page is:
>>>>
>>>> Exception name: No result defined for action KeywordListAction and
>>>> result input
>>>> No result defined for action KeywordListAction and result input at
>>>>
>>>> com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375)
>>>> at
>>>>
>>>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
>>>> at
>>>>
>>>> com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
>>>> at
>>>>
>>>> org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept
>>>> (AnnotationValidationInterceptor.java:68) at
>>>> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept
>>>>
>>>> Is this a bug or do I need to do something differently for 2.2?
>>>>
>>>> Raj.
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail:user-unsubscr...@struts.apache.org
>>>> For additional commands, e-mail:user-h...@struts.apache.org
>>>>
>>>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to