Hi,
The preffered way now is to extend CustomValidator and call one of the error(... methods of AbstractValidator when a validation error occurs.
This could be simple like in RequiredValidator
public void onValidate(String value)
{
// Check value
if (Strings.isEmpty(value))
{
error();
}
}or with a more customized error message like:
protected void error(String input, FormComponent component, ConversionException e)
{
Map<String, Object> ctx = messageModel();
ctx.put("fieldDescription", inputElement.getDescription());
ctx.put("input", input);
String resourceKey = "typeError." + e.getTargetType().getName();
error(resourceKey, ctx);
}
I don't know about the exception you got, but your best bet is to go for version 0.9.18 beta which Martijn is releasing just now.
We'll keep up the work if you keep on using it ;)!
Eelco
Stefan Lindner wrote:
Hello all,
two things about validators:
1. In ...17beta there was an Interface AbstractValidator() with the method public ValidationErrorMessage validate(FormComponent component) now the validate method does not return any value, it's a void method. How can I mark the component as invalid? 2. Now I use a preddfined validator. <TextField>.add(IntegerValidator.range(0, 100)); When the input in this text field is invalid an exception is thrown: wicket.WicketRuntimeException: Method public abstract void wicket.markup.html.form.IFormSubmitListener.onFormSubmitted() of interface IFormSubmitListener threw an exception at wicket.protocol.http.WebRequestCycle.invokeInterface(WebRequestCycle.jav a:406) at wicket.protocol.http.WebRequestCycle.invokeInterface(WebRequestCycle.jav a:424) at wicket.protocol.http.WebRequestCycle.callComponentListener(WebRequestCyc le.java:333) at wicket.protocol.http.WebRequestCycle.onRender(WebRequestCycle.java:205) at wicket.RequestCycle.render(RequestCycle.java:436) at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:163) at wicket.protocol.http.WicketServlet.doPost(WicketServlet.java:185) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) ...
Beside this problems: I am new to Wicket but it seems to be the framework I was looking for For a long time. Great work! Keep on going!
Regards
Stefan Lindner
------------------------------------------------------------------------
--
Visionet GmbH, Am Weichselgarten 7, 91058 Erlangen
Tel.: (09131)691-230, FAX: (09131)691-111
E-Mail: mailto:[EMAIL PROTECTED], Internet:
http://www.visionet.de
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
