Re: Handling the fileuploadexception

2015-06-11 Thread Stephen Nutbrown
Hi again, apologies for multiple posts.

I would actually really be interested in a file type validator as I am
currently doing this on the server too - in the onValidateFromX, which
fires after the upload has happened.
I'll wait for some feedback on this one before creating a file type
validator, but I will do that too (taking into account any notes on
this one).
Perhaps these two together could be added to Tapestry-Uploads or as a
separate dependency. I would think that any site which has upload
functionality wants to have something to stop massive files being
uploaded, and I would also expect that clearing the form is
problematic for most of those sites, so i'm still a bit surprised this
hasn't been an issue for anyone else.

Thanks,
Steve

On 11 June 2015 at 21:51, Stephen Nutbrown  wrote:
> Hello!
>
> I am back, and with a working solution. Before using this solution for
> any of your own projects, please take the following into
> consideration:
>
> - I am not an experienced javascript developer, i've done my best to
> hack something together based on tapestrys own validation.js and the
> stackoverflow post which was linked to.
>
> - I haven't tested it on all browsers, but it should be supported on
> all modern browsers (as per the other article I linked to), and I have
> set the clientside validation to accept it if the required support
> isn't there - the server side validation will catch it but it's more
> efficient to catch it client side.
>
> - I have absolutely no clue how to package this up into a .jar file to
> make it easier to distribute, ideally it would be nice if this is
> taken as a proof of concept and added to tapestry-upload, or if it was
> made into a .jar which was distributed on maven - unfortunately this
> would be a bit of a learning curve for me and i'm so busy it's
> unbelievable. Of course if you have the time to take my code and do
> that with it, please do and share it - do with it whatever you want.
> One day I would like to be a Tapestry contributor, but it'll take me a
> while to be ready.
>
> That said, here it is (I'm sure Thiago or someone else will probably
> correct some parts if it's wrong):
>
> - maxfilesize.js (attached) belongs in src/main/resources/META-INF/modules
>
> - MaxUploadSize.java belongs where you want to place it, I put it in a
> validators package, so for me it is
> src/main/java/com/football/news/validators, but for you it will be
> src/main/java/your/project/package
>
> - I added the following line to my app.properties
> (src/main/webapp/WEB-INF/app.properties), perhaps there is a better
> properties file for this:
> data-validate-filesize=The file size is too big.
>
> - I contributed the validator in my AppModule, like this:
>
> public static void
> contributeFieldValidatorSource(MappedConfiguration
> configuration, final JavaScriptSupport javaScriptSupport) {
> configuration.add("fileSizeValidator", new
> MaxUploadSize(Integer.class, UploadedFile.class,
> "data-validate-filesize", javaScriptSupport));
> }
>
> I'm trying to help others by uploading this, but please take my
> solution with a pinch of salt, some parts of tapestry are still some
> unknown "magic" to me.
>
> Any feedback is really appreciated, it will help people seeing this in
> future and will also help me to update my local version. I would think
> a filetype validator similar to this one would also be possible.
>
> Thanks,
> Steve
>
> On 10 June 2015 at 08:52, Stephen Nutbrown  wrote:
>> 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
>>  wrote:
>>> On Tue, 09 Jun 2015 19:01:33 -0300, Stephen Nutbrown 
>>> 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

Precompile my js module at startup

2015-06-11 Thread Charlouze
Hey tapestry users !

What would be the best way to compile my coffee files to minimized js files
?

I need that feature because I have to refresh the first page several at
startup in order not to get requirejs to timeout.

Cheers,
Charles.


Re: Ajax and Component's inside Zones

2015-06-11 Thread Thiago H de Paula Figueiredo
On Thu, 11 Jun 2015 07:45:06 -0300, Casey Link   
wrote:



 


ActionLink and EventLink are not supposed to do AJAX requests without a  
zone parameter, so I really don't know how they made AJAX requests in your  
case. Try adding zone="^".


2. I've tried using an eventlink instead of an actionlink, but clicking  
it still causes a full page refresh


EventLink and ActionLink are almost the same, me considering ActionLink to  
be mostly deprecated, so use EventLink instead and to handle it, just use  
on[event name](). If you use on[event name]From[component id], the event  
handler will only work in the class associated to the template where the  
component was declared, because component ids are local to where they were  
declared. ActionLink always uses the same event name, so you end up  
needing to use the component id in the event handler method name or  
@OnEvent annotation.


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



Ajax and Component's inside Zones

2015-06-11 Thread Casey Link
I have a grid component with some complex features I want to reuse in various 
places of my app.

However, I'm having a problem preserving the AJAXy behavior.

Before I extracted the grid into its own component the tml looked like this:


  
  
 ...
   
 
Remove Item 
   
  

  


The action link was AJAXy with the handler Object onActionFromRemoveItem(Long 
id){}

Then, I extracted the table grid into a component and replaced it in my TML 
with:

 

But now the AJAX behavior of the remove button is lost. 

Things to note:

1. The Zone is in the Page's TML, there is no Zone in the component TML
2. I've tried using an eventlink instead of an actionlink, but clicking it 
still causes a full page refresh
3. In my event or actionlink handler (in the Page class!), _request.isXHR() == 
false

How do I make the actionlink/eventlink inside my custom component respect the 
ajax Zone they are placed in inside the parent?

Cheers,

Casey


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