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 implementingActionProxy
. To set themethod
attribute you should extendDefaultActionProxy
and set the super protected attribute via yoursetMethod
implementation.Then you should extend
DefaultActionProxyFactory
and substituteDefaultActionProxy
in thecreateActionProxy()
.After that modify
struts.xml
and overridewith your own factory.
But preferably to set the method in the parameters with the
method:
prefix or usingsetMethod
in theActionMapping
class that you could get from theActionContext
or you can extend theDefaultActionMapper
to get the mapping you need. See docs.