that is what validators are for
-igor
On Wed, Jun 4, 2008 at 9:43 PM, Ned Collyer <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have the requirement where I need to validate things like image format,
> height, width etc for a file upload.
>
> I'd like to do this using validators, which I can do - but im curious if its
> the right way.
>
>
> Here is what I currently have.
>
>
>
> form.add(fileUploadField = new FileUploadField("fileInput") {
> protected void convertInput() {
> setConvertedInput(getFileUpload());
> }
> });
>
> fileUploadField.add(new AbstractValidator() {
> protected void onValidate(IValidatable validatable) {
> FileUpload fileUpload = (FileUpload)validatable.getValue();
> if (fileUpload.getContentType().equals("text/plain")) {
> error(validatable);
> }
> }
>
> protected String resourceKey() {
> return "CustomFileError";
> }
> });
>
>
> This works... but is it correct?
>
> I'm not handling it in the onSubmit - and don't believe I should have to -
> despite the examples.
>
>
> I have double submit implemented on my base form in a similar fashion to
> what igor recommends here
> http://www.nabble.com/double-form-submission-handling---tp13816084p13850262.html
> - which means I only execute the "submit" if all the validation passes.
> This works SUPER AWESOME thus far :)
> --
> View this message in context:
> http://www.nabble.com/Best-way-of-validating-FileUploadField-tp17662018p17662018.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]