Thanks for sharing this solution, Boris! Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov
On Fri, May 12, 2017 at 3:23 PM, Boris Goldowsky <[email protected]> wrote: > For anyone who may have a similar issue and find this thread, here’s the > workaround I used. > > Desired behavior was to have an AJAX submit on a form that includes a > drawing widget. The drawing can’t be saved directly; it needs to be asked > to export its data into a hidden text field which can be saved. The > widget’s export operation returns a Promise. > > Strategy: > > 1) Instead of an AjaxSubmit button, I’m using a regular <button> > 2) That button has an onclick that invokes the export operation, with a > “then” clause that emits a custom javascript event. > 3) I attach an AjaxFormSubmitBehavior listening to this custom event, so > the form is submitted when the data is ready. > > I think it would be a nice feature in the future to think through a > reasonable integration of the ajax handlers with Promises, as they are > likely to become more commonly used now that they are reasonably > standardized. > > Boris > > > On 5/3/17, 3:08 PM, "Martin Grigorov" <[email protected]> wrote: > > Hi, > > No, Wicket doesn't use the return values for all handlers but > "preconditions" [1]. > And even for preconditions the only value that matters is the literal > *false.* > > > 1. > https://github.com/apache/wicket/blob/b24decd2f60983c11e75e5f2c34d0c > 6a93b56426/wicket-core/src/main/java/org/apache/wicket/ > ajax/res/js/wicket-ajax-jquery.js#L614 > > Martin Grigorov > Wicket Training and Consulting > https://twitter.com/mtgrigorov > > On Wed, May 3, 2017 at 5:52 PM, Boris Goldowsky <[email protected]> > wrote: > > > Is there any way to use a method that returns a promise as the > onBefore of > > an IAxaxCallListener? I don’t want the ajax operation to move > forward > > until the promise resolves. Due to the nature of promises in > Javascript, > > there doesn’t seem to be a way to simply wait for it. > > > > Boris > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
