Hi there,
I am trying to get validation going for my application and so far
nothing works. I would like to use annotations. Here is what I try to
do:
package ...
import ...
@Results({
@Result(name = "success", value = "/jsp/hitlist.jsp"),
// value = "hitlist.action", type =
ServletActionRedirectResult.class),
@Result(name = "error", value = "/jsp/index.jsp")
})
@ParentPackage("default")
@Validation()
public class SearchAction extends ActionSupport
{
private SearchParam searchParam;
@Validations(
expressions = [EMAIL PROTECTED](expression =
"searchParam.keywords ne null and searchParam.location ne null" message
= "Wrong search parameters")
}
)
public String search()
{
// do search
return SUCCESS;
}
public SearchParam getSearchParam()
{
return searchParam;
}
public void setSearchParam(SearchParam searchParam)
{
this.searchParam = searchParam;
}
}
SearchParam is class containing two properties keywords and location
(with matching getter and setters). When I run the application without
any annotation it works fine. What I mean is that the keywords and
locations field get properly passed into action. The problem starts with
validation.
Currently I get the following error:
>>>
No result defined for action SearchAction and result input No result
defined for action SearchAction and result input at
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:345)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
at
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
at
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
at
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at....
>>>
Can anyone see what I am doing wrong? Is it actually possible to have
validation on 'complex' datatypes as I am trying to do with SearchParam?
Or do I need keywords and locations as simple String properties in the
Action directly?
I also tried to apply the ExpressionValidator annotation directly on
setSearchParam method, but then I got the following error message:
>>>
caught OgnlException while setting property 'methodName' on type '
com.opensymphony.xwork2.validator.validators.ExpressionValidator'.
ognl.NoSuchPropertyException:
com.opensymphony.xwork2.validator.validators.ExpressionValidator.methodName
>>>
Any help is greatly appreciated.
--Hardy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]