I'm using openSymphony 2.1.2 and I have some old code that was written for older versions of openSymphony.
As you can see, it tells me that ActionProxy
has no method setMethod(String)
.
It probably used to have. But not anymore.
But it still has a method String getMethod()
. So how is there a method variable that I can get, but not set? How do I set the method in the new API?
import com.opensymphony.xwork2.ActionProxy;
protected ActionProxy proxy = null;
//used to work with older versions of openSymphony, now there's a compilation error here:
//The method setMethod(String) is undefined for the type ActionProxy
proxy.setMethod(methodName);
UPDATE:
I am working on a system (which was not written by me) that uses openSymphony 2.1. and Struts 2.3.8.
On that system, I am trying to apply the following code:
Action Unit Testing with Struts 2.0. Part 2
That code fails with the versions of openSymphony and Struts my project uses. So I am trying to upgrade that code to the newer versions of openSymphony and Struts.
I need it in order to be able to simulate running the struts actions from my system, in a system that is based on a different framework.
DefaultActionProxy
is implementing ActionProxy
. To set the method
attribute you should extend DefaultActionProxy
and set the super protected attribute via your setMethod
implementation.
Then you should extend DefaultActionProxyFactory
and substitute DefaultActionProxy
in the createActionProxy()
.
After that modify struts.xml
and override
<bean type="com.opensymphony.xwork2.ActionProxyFactory" name="xwork" ... />
with your own factory.
But preferably to set the method in the parameters with the method:
prefix or using setMethod
in the ActionMapping
class that you could get from the ActionContext
or you can extend the DefaultActionMapper
to get the mapping you need. See docs.