not necessarily. the value doesn't have to be a string.

i feel this is quite elegant as it is and i think we should fix by documenting that you use getRequestX() to get the value to validate, which might be getRequestInt(), getRequestBoolean() or some other method. in particular, choices can be validated by id or index this way using getRequestInt()..

another thing we could do that would obviate the need to write validators of the kind you're suggesting is to supply validators that solve typical problems. if you're trying to validate that a value is not empty, use RequiredValidator. if you want it to have a specific value, use PatternValidator. we should document this too...

could you open a doc bug?

thx!

Johan Compagner wrote:

Hi,

This is the current method:

/**
* Validates the given input. The input corresponds to the input from the request for a
* component.
* @param component Component to validate
*/
public void validate(final FormComponent component);



But for a beginner it is not very clear what do to in this method For example:

component.getModelObjectAsString()  sound very reasonalble..

But the model is not yet populated at this place.

You have to do component.getRequestString()

I don't like this, that is a line of code that has to be there in every validate method...
So we should already supply that through the method.


/**
* Validates the given input. The input corresponds to the input string from the request for the given component.
* @param component Component to validate
* @param value The value string that the user entered.
*/
public void validate(final FormComponent component, String value);


People don't make mistakes and it is much more clear that that is the value that should be validated..

johan



-------------------------------------------------------
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



-------------------------------------------------------
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

Reply via email to