If you're extending a class in the com.opensymphony.xwork2 package you may not be able to migrate across deprecated imports. In this case you're extending com.opensymphony.xwork2.validator.ValidationInterceptor and so you will need to retain the deprecated imports. It's not that something was missed, I just didn't get around to introducing org.apache.struts2 variants for every class (ensuring cross-compatibility during this process is not always simple). So you may end up with some code or classes that unfortunately can't be migrated until 7.0.
On Thu, Nov 28, 2024 at 8:27 PM Greg Huber <gregh3...@gmail.com> wrote: > > 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. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org For additional commands, e-mail: dev-h...@struts.apache.org