You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Voronetskyy <ye...@gmail.com> on 2007/10/14 22:50:16 UTC
PatternValidator for file name
Hello,
I'm neophyte of Wicket...
I'am using PatternValidator to test file name in the upload component.
I wrote the code :
private class FileUploadForm extends Form
{
private FileUploadField fileUploadField;
public FileUploadForm(String name)
{
super(name);
setMultiPart(true);
add(fileUploadField = new FileUploadField("fileInput"));
fileUploadField.add(new
PatternValidator(Pattern.compile("^*.JPG$")));
}
// some code
}
When submiting form with any file name, like 'D:\foto\alena.JPG' that
matches my mask "^*.JPG$", I have a message that my file name is not
matching the mask.
Can anyone tell me what is wrong with my code.
Thank you in advance for your help,
Yevgen.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: PatternValidator for file name
Posted by Igor Vaynberg <ig...@gmail.com>.
the modelobject of fileuploadfield is of type FileUpload not the filename
string, so you cant use a validator that expects a string.
you should do this check in your onsubmit handler.
-igor
On 10/14/07, Voronetskyy <ye...@gmail.com> wrote:
>
> Hello,
>
> I'm neophyte of Wicket...
>
> I'am using PatternValidator to test file name in the upload component.
> I wrote the code :
>
> private class FileUploadForm extends Form
> {
> private FileUploadField fileUploadField;
> public FileUploadForm(String name)
> {
> super(name);
> setMultiPart(true);
>
> add(fileUploadField = new FileUploadField("fileInput"));
>
> fileUploadField.add(new
> PatternValidator(Pattern.compile("^*.JPG$")));
> }
> // some code
> }
>
> When submiting form with any file name, like 'D:\foto\alena.JPG' that
> matches my mask "^*.JPG$", I have a message that my file name is not
> matching the mask.
>
> Can anyone tell me what is wrong with my code.
>
> Thank you in advance for your help,
> Yevgen.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>