@Retention(value=RUNTIME) @Target(value=METHOD) public @interface Validate
Controller class.
The validation method is executed before the exposed method annotated. If the validation
method executes without any exception, the target exposed method is called, otherwise,
Crux ValidationErrorHandler is called to handle the error reported by validation
method, and the exposed method is not called.
See the following example:
Any call made to the previous controller method (@Controller("myController") public class MyController {@Validate@Exposepublic void myEventHandler() { Window.alert("event dispatched!"); } //Validate Method for myEventHandler method public void validateMyEventHandler() { if (someTest) { throw new MyValidationException("Validation message"); } } }
myEventHandler) will be preceded
by a call to validation method (validateMyEventHandler). It applies to any event
triggered by a .crux.xml or .view.xml page.
Validation method must obey the following constraints:
1) Be annotated with @Validate annotation.
2) Have at least package visibility.
3) Have no parameter or have only one parameter, with type equals to the type of the event handled by the method.
For example:
@Controller("myController") public class MyController {@Validate@Exposepublic void myEventHandler(ClickEventevent) { Window.alert("event dispatched!"); } //Validate Method for myEventHandler method public void validateMyEventHandler(ClickEventevent) { if (someTest) { throw new MyValidationException("Validation message"); } } }
Expose,
Controllerpublic abstract String value
validate<MethodName>(First capitalized)Copyright © 2015. All rights reserved.