
|
If you were logged in you would be able to see more operations.
|
|
|
|
Environment:
|
Windows XP, JDK 1.4.2
|
|
|
The ValidationInterceptor gets invoked no matter what. It would be nice if you could specify that it wouldn't be invoked for certain cases. This allows the user to specify less actions in xwork.xml. For example, I don't want to invoke it when users click on Cancel, Delete or when they're first requesting the form. Here's a method from the custom interceptor I wrote.
protected void before(ActionInvocation invocation) throws Exception {
Action action = invocation.getAction();
String context = invocation.getProxy().getActionName();
final Map parameters = ActionContext.getContext().getParameters();
// don't validate on cancel, delete or GET
if (ServletActionContext.getRequest().getMethod().equals("GET")) {
if (log.isDebugEnabled()) {
log.debug("Cancelling validation, detected GET request");
}
} else if (parameters.containsKey("cancel") || parameters.containsKey("delete")) {
if (log.isDebugEnabled()) {
log.debug("Cancelling validation, detected clicking cancel or delete");
}
} else {
if (log.isDebugEnabled()) {
log.debug("Validating " + invocation.getProxy().getNamespace() + invocation.getProxy().getActionName() + ".");
}
ActionValidatorManager.validate(action, context);
}
}
I suppose it's easy enough to extend, but I thought this might be a nice feature.
|
|
Description
|
The ValidationInterceptor gets invoked no matter what. It would be nice if you could specify that it wouldn't be invoked for certain cases. This allows the user to specify less actions in xwork.xml. For example, I don't want to invoke it when users click on Cancel, Delete or when they're first requesting the form. Here's a method from the custom interceptor I wrote.
protected void before(ActionInvocation invocation) throws Exception {
Action action = invocation.getAction();
String context = invocation.getProxy().getActionName();
final Map parameters = ActionContext.getContext().getParameters();
// don't validate on cancel, delete or GET
if (ServletActionContext.getRequest().getMethod().equals("GET")) {
if (log.isDebugEnabled()) {
log.debug("Cancelling validation, detected GET request");
}
} else if (parameters.containsKey("cancel") || parameters.containsKey("delete")) {
if (log.isDebugEnabled()) {
log.debug("Cancelling validation, detected clicking cancel or delete");
}
} else {
if (log.isDebugEnabled()) {
log.debug("Validating " + invocation.getProxy().getNamespace() + invocation.getProxy().getActionName() + ".");
}
ActionValidatorManager.validate(action, context);
}
}
I suppose it's easy enough to extend, but I thought this might be a nice feature. |
Show » |
|