the api could be made more compact if we discouraged IValidator implementations and had AbstractValidator save the component on validate() calls:
public void validate(final FormComponent component)
{
setComponent(component);
onValidate(component.getRequestString());
}public abstract void onValidate(String value);
and in AbstractValidator all the FormComponent parameters would go away which would be nice for brevity in implementing validators:
public abstract class AbstractValidator implements IValidator
{
public void error(final FormComponent component, final String input)
public void error(final FormComponent component, final String resourceKey,
final IModel resourceModel)
public void error(final FormComponent component, final String resourceKey, final Map map)
public void error(final FormComponent component, final String resourceKey, final String input)
protected Map messageModel(final FormComponent component, final String input)
protected String resourceKey(final FormComponent component)
}
becomes:
public abstract class AbstractValidator implements IValidator
{
public void error(final String input)
public void error(final String resourceKey, final IModel resourceModel)
public void error(final String resourceKey, final Map map)
public void error(final String resourceKey, final String input)
protected Map messageModel(final String input)
protected String resourceKey()
}the only bummer is that now AbstractValidator is stateful, which means that sharing validators across sessions won't work.
i think my tendency here is to go ahead and make it briefer and serialize access to validators in Form with synchronized to make them threadsafe. 99.9% of the time, the lock will be instantly acquired. when two forms are submitted exactly simultaneously, one of them might pause for a few nanoseconds if it wants to access a shared validator that is in use. the only downside i can see is that if someone did something compute crazy in their validator, the system might stop until it was done. but the solution to that is easy... either /don't do that/ or just stop sharing the validator. what's cool about this is that you can probably save a bunch of session state by making validators static. in fact, RequiredValidator could be a singleton since it has no state! this would definitely cut down on memory use and session size... at the expense of a negligible decrease in liveness.
thoughts?
jon
------------------------------------------------------- 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-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-develop
