Hi,

Yes, copying and adapting one for the validators is exactly what I did
in the end using the twitter library they have. However, I found it a
bit difficult to do because the current validator seems to use a
coffee script (Something i'm not familiar with, I struggle with JS as
it is!). So I ended up getting the validator.js from running my T5
program and downloading it (I'm sure there is a better way, but  I
couldn't find this .js file otherwise), and then I had to figure out
how to use require.js properly as I wasn't used to it. I'm sure now I
know how to do it, it'll be easy enough, but when I did the twitter
one it actually took me a fair bit of time to figure out how to do it
- but I got there in the end.

Perhaps when I make this i'll note down some steps and I can post them
somewhere to make it easier for other people. It might be a few days
until I get the time, but i'll certainly do that.

Thanks,
Steve



On 10 June 2015 at 01:38, Thiago H de Paula Figueiredo
<thiag...@gmail.com> wrote:
> On Tue, 09 Jun 2015 19:01:33 -0300, Stephen Nutbrown <steves...@gmail.com>
> wrote:
>
>> Hi,
>
>
> Hi!
>
>>
>> I saw some posts on StackOverflow about validating files using
>> JavaScript's
>> files api (it looks fairly new so may not be suitable for projects which
>> need to support old browsers):
>>
>>
>> https://www.google.co.uk/url?sa=t&source=web&rct=j&ei=omB3Vb_MKKi07QbRvoDYBQ&url=http://stackoverflow.com/questions/3717793/javascript-file-upload-size-validation&ved=0CB0QFjAA&usg=AFQjCNGck_7qB8b7VzFExHQM72vzF6JxZA&sig2=XgAbDcP-E8-daXfAyP0tEg
>
>
> Interesting! Thanks! I learned something new today . . .
>
>> Some time ago I implemented a client side twitter validator to check the
>> length of text field values (it gets a bit complicated because links
>> count> as fewer characters etc).
>
>
> Twitter has a JS library that does this character counting, so it's just a
> matter of copying and adapting the MaxLength validator from Tapestry.
>
>> I can have a go at doing the same for the
>> fileuploader and can put whatever I make up on github somewhere.
>
>
> Don't forget to post an announcement here. :)
>
>> It won't
>> work on old browsers as per:
>>
>> https://www.google.co.uk/url?sa=t&source=web&rct=j&ei=Y2F3Vbf0IIet7AarkoLgBA&url=http://caniuse.com/fileapi&ved=0CB0QFjAA&usg=AFQjCNEufMjex_NEpHKkWV7k-pakFWDNJQ&sig2=-hTtFzGroBPZc9w0v1bGIA
>>
>> I'm a bit surprised that this doesn't exist,
>
>
> What's "this"? :)
>
>
> I thought it would and so I
>>
>> expected that I was doing something horribly wrong. I'll come back when I
>> have it working as it may help others.
>>
>> Thanks,
>> Steve
>>  On 9 Jun 2015 20:06, "Thiago H de Paula Figueiredo" <thiag...@gmail.com>
>> wrote:
>>
>>> On Tue, 09 Jun 2015 14:39:54 -0300, Stephen Nutbrown
>>> <steves...@gmail.com>
>>> wrote:
>>>
>>>  Hi Thiago,
>>>>
>>>>
>>>
>>> Hi!
>>>
>>>
>>>> That's interesting. Perhaps the documentation wants updating. It says:
>>>> "Note the importance of return this;. A void event handler method, or
>>>> one that returns null, will result in the FileUploadException being
>>>> reported to the user as an uncaught runtime exception."
>>>>
>>>> https://tapestry.apache.org/uploading-files.html
>>>>
>>>
>>> Not returning "this" isn't just for uploading exceptions: it's for all
>>> event handler methods, so I don't think it makes sense to put this
>>> warning
>>> in uploading-files.html.
>>>
>>> In your original code, returning "this", if you annotated your field with
>>> @Persist(PersistenceConstants.FLASH), the message would appear. In this
>>> very case, it appears to be the right thing to do (return "this"), as
>>> otherwise Tapestry still considers the event as not handled and the
>>> generic
>>> exception handling is used.
>>>
>>> --
>>> Thiago H. de Paula Figueiredo
>>> Tapestry, Java and Hibernate consultant and developer
>>> http://machina.com.br
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>
>>>
>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to