Re: AjaxUpload and BeanEditContext

2015-05-29 Thread Peter Hvass
*tumble weeds* :)

I'll have another crack at this some time and update with results but will
keep these cookies fresh in case anyone has any ideas!

*Peter Anders Hvass* - *http://theru.in http://theru.in*

On Fri, May 22, 2015 at 4:25 PM, Peter Hvass pe...@theru.in wrote:

 Hello all,

 tl;dr - need to push a BeanEditContext before AjaxUpload's upload event
 and pop just afterwards.

 I've been playing around with this;
 https://gist.github.com/xfyre/83f82f6e5145ee041217

 It appears to be based on Tawus' AjaxUpload component here;
 https://github.com/tawus/tawus/tree/master/tawus-ajaxupload

 The difference being the client-side scripts use a different library and
 have been updated for 5.4's Require.js stuff.

 When you select a file to upload, a server-side event entitled 'upload' is
 triggered via XHR.

 Unfortunately this doesn't play nice with my custom property blocks that
 rely on accessing BeanEditContext through the environment.

 BeanEditContext is pushed using FormSupport in components like
 BeanEditForm - both for the duration of a form action and during render.

 I've been toying around trying to figure out a way that I could push/pop
 BeanEditContext before and after the upload event but have been failing
 (hard) so far.

 I was just wondering if anyone else may already have tackled this - any
 ideas?

 I was thinking about trying to intercept the upload event (couldn't find
 anything that would let me do this - i.e.: a more generic FormSupport sort
 of 'doohickey').

 (For some background; I set up a data type and custom property block to
 catch uploads of files related to my database layer; this is lovely - it
 lets me generically handle create/update/display pushing/deleting files on
 Amazon S3 and storing/replacing their metadata in the database. I'm using
 Apache Cayenne - so the delete side of things is handled nicely by a
 pre-removal event listener on that end. This works nicely for the standard
 Upload component but when zones come into play, not so much. Enter
 AjaxUpload component. This is for an inline-editable grid-type component I
 use (click cell - reveal form+field - change - persist to database).

 Thanks a ton!
 Peter



Re: AjaxUpload and BeanEditContext

2015-05-29 Thread Lance Java
You can probably contribute a ComponentEventRequestFilter to the
ComponentEventRequestHandler.

I always find the diagram at the bottom of this page useful
http://tapestry.apache.org/request-processing.html


Re: AjaxUpload and BeanEditContext

2015-05-29 Thread Chris Poulsen
I dont know if it is enough to wrap the upload component and have the
wrapper's handler push BEC, trigger custom event with callback result, pop
BEC after trigger returns and then return the callback result to the inner
handler?

On Fri, May 29, 2015 at 3:56 PM, Lance Java lance.j...@googlemail.com
wrote:

 You can probably contribute a ComponentEventRequestFilter to the
 ComponentEventRequestHandler.

 I always find the diagram at the bottom of this page useful
 http://tapestry.apache.org/request-processing.html



Re: AjaxUpload and BeanEditContext

2015-05-29 Thread Lance Java
Another option is adding a mixin to the AjaxUpload. And perhaps attach it
to every instance using a ComponentClassTransformWorker2 eg:
https://tawus.wordpress.com/2011/08/01/tapestry-mixins-classtransformations/