6.7.0 com.opensymphony.xwork2.ActionInvocation /ActionProxy package change

Greg Huber <[email protected]>
Newsgroups gmane.comp.jakarta.struts.devel
Message-ID <[email protected]>
When updating one of my interceptors to org.apache.struts2. package, the 
class won't compile now:

The method doBeforeInvocation(com.opensymphony.xwork2.ActionInvocation) 
in the type ValidationInterceptor is not applicable for the arguments 
(org.apache.struts2.ActionInvocation)

The method doIntercept(ActionInvocation) of type 
DMIAwareValidationInterceptor must override or implement a supertype method

The method getValidationContext(ActionProxy) of type 
DMIAwareValidationInterceptor must override or implement a supertype method

The method getValidationContext(com.opensymphony.xwork2.ActionProxy) in 
the type ValidationInterceptor is not applicable for the arguments 
(org.apache.struts2.ActionProxy)

Maybe something got missed?

#####

Here is my class

package my.ui.struts2.interceptors;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsConstants;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.validator.ValidationInterceptor;

/**
  * Define our own context to support method's names in validation file 
name if
  * DMI is enabled and method was specified validation file name will be
  * constructed like this: -
  *
  * <ActionClass>-<actionAlias>!<methodName>-validation.xml
  */
public class DMIAwareValidationInterceptor extends ValidationInterceptor {

     private static final long serialVersionUID = 9007212648956424490L;
     private boolean dmiEnabled = false;

@Inject(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION)
     public void setEnableDynamicMethodInvocation(String value) {
         dmiEnabled = Boolean.parseBoolean(value);
     }

     @Override
     protected String doIntercept(ActionInvocation invocation) throws 
Exception {

         // Only run validator for a post if on DMI so handles errors 
correctly
         // final ActionContext context = invocation.getInvocationContext();
         final HttpServletRequest request = (HttpServletRequest) invocation
.getInvocationContext().get(ServletActionContext.HTTP_REQUEST);
         if (dmiEnabled && "POST".equals(request.getMethod()) || 
!dmiEnabled) {
             doBeforeInvocation(invocation);
         }
         return invocation.invoke();
     }

     /**
      * @see 
com.opensymphony.xwork2.validator.ValidationInterceptor#getValidationContext(com.opensymphony.xwork2.ActionProxy)
      */
     @Override
     protected String getValidationContext(ActionProxy proxy) {
         if (dmiEnabled && StringUtils.isNotEmpty(proxy.getMethod())) {
             return proxy.getActionName() + "!" + proxy.getMethod();
         }
         return super.getValidationContext(proxy);
     }

}


On 26/11/2024 06:06, Lukasz Lenart wrote:
> Internal changes
> A lot of classes have been marked as deprecated because of relocation
> of them into a new package. All classes from package
> com.opensymphony.xwork2  will be moved into org.apache.struts2  in
> Struts 7 and this deprecation can help you adapt to incoming changes.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.