Hey guys, just wanted to finally follow up. Time has been scarce lately so I
didn't get a chance to post my findings. Again thanks to Taha and especially
Joost for helping with this issue -- you guys made me look in the right
places especially that JIRA issue. 

So basically I do have the same problem as described in
https://issues.apache.org/jira/browse/TAP5-1533.
The problem is that after streamed response downloads ajax requests were
being stopped because  of the window unload event. The patch is correct but
unfortunately I can't/didn't figure out how to use my own version of
Tapestry.js

So I think I found a relatively elegant solution to use until the patch/fix
comes out. Mixins to the rescue!
So for each link that causes a streamed response to be returned add the
following mixin which will upon the click event set Tapestry.windowUnloaded
property to false. And voila, all the ajax will still work on the page.  The
key to this is that the unload event is handled before the click event
giving the mixin the chance to properly reset the state.  StreamedResponses
are sort of the exception to the rule that a new non ajax response doesn't
always mean a new page/window. This way I don't have to deal with
downloading through an iframe or new window.

<t:linksubmit t:id="download"
t:mixins="streamedResponsePatch">Download</t:linksubmit>

@Import(library="StreamedResponsePatch.js")
public class StreamedResponsePatch
{

   @Inject
   private JavaScriptSupport javaScriptSupport;

   @InjectContainer
   private ClientElement clientElement;

   @AfterRender
   public void after()
   {
      JSONObject j = new JSONObject();
      j.put("elementId", this.clientElement.getClientId());
      this.javaScriptSupport.addInitializerCall("StreamedResponsePatch", j);
   }

}


//
StreamedResponsePatch=Class.create(
{
  initialize: function(spec)
  {
      this.elementId = spec.elementId;
      Event.observe($(this.elementId), 'click',
this.update.bindAsEventListener(this));
  },

  update: function(e)
  {Tapestry.windowUnloaded = false;},

});

Tapestry.Initializer.StreamedResponsePatch = function(spec)
{new StreamedResponsePatch(spec);}

 

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/StreamResponse-and-inPlace-Grid-question-tp4760076p4837399.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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

Reply via email to