Re: AjaxCallListener and promises

2017-05-12 Thread Martin Grigorov
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 
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 
> 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"  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 
> 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: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: AjaxCallListener and promises

2017-05-12 Thread Boris Goldowsky
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 
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"  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/b24decd2f60983c11e75e5f2c34d0c6a93b56426/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  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: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AjaxCallListener and promises

2017-05-03 Thread Martin Grigorov
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/b24decd2f60983c11e75e5f2c34d0c6a93b56426/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  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
>
>


Re: AjaxCallListener

2016-09-27 Thread durairaj t
Thank you!



On Tue, Sep 27, 2016 at 10:21 AM, Martin Grigorov 
wrote:

> Hi,
>
> decorateScript() means "do something before and after".
> So you need IAjaxCallListener's onBefore() and onComplete()
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Tue, Sep 27, 2016 at 4:11 PM, durairaj t 
> wrote:
>
> > Based on the wicket 1.5 comments in IAjaxCallDecorator.java,
> > I think, I may need to use "beforeSend" for "decorateScript" and
> > "onSuccess" for "decorateOnSuccessScript".
> >
> > But I'm not sure.  Any help?
> >
> > *Code snippet from wicket 1.5  IAjaxCallDecorator.java*
> >
> > /**
> > * Decorates the script that performs the ajax call
> > *
> > * @param component
> > * @param script
> > * @return decorated script
> > */
> > CharSequence decorateScript(Component component, CharSequence script);
> >
> > /**
> > * Decorates the onSuccess handler script
> > *
> > * @param component
> > * @param script
> > * @return decorated onSuccess handler script
> > */
> > CharSequence decorateOnSuccessScript(Component component, CharSequence
> > script);
> >
> > On Tue, Sep 27, 2016 at 8:54 AM, durairaj t 
> > wrote:
> >
> > > Hi,
> > >
> > > I'm replacing "decorateScript(Component arg0,CharSequence script)" with
> > > "AjaxRequestAttributes#getSuccessHandler(Component component)"
> > > and
> > > "decorateOnSuccessScript(Component arg0,CharSequence script)"  with
> > > "AjaxRequestAttributes# onSuccess(."
> > >
> > >
> > > *Is it correct?*
> > >
> > >
> > >
> > >
> > > On Mon, Sep 26, 2016 at 4:35 PM, Tobias Soloschenko <
> > > tobiassolosche...@googlemail.com> wrote:
> > >
> > >> Hi,
> > >>
> > >> I just googled for it:
> > >>
> > >> http://apache-wicket.1842946.n4.nabble.com/Migration-1-5-gt-
> > >> 6-CancelEventIfNoAjaxDecorator-td4652609.html
> > >>
> > >> Hope this helps.
> > >>
> > >> kind regards
> > >>
> > >> Tobias
> > >>
> > >> > Am 26.09.2016 um 22:13 schrieb durairaj t :
> > >> >
> > >> > How to replace the "new CancelEventIfNoAjaxDecorator();" in
> wicket 7
> > >> > AjaxCallListener?
> > >> >
> > >> > Any help?
> > >>
> > >
> > >
> >
>


Re: AjaxCallListener

2016-09-27 Thread Martin Grigorov
Hi,

decorateScript() means "do something before and after".
So you need IAjaxCallListener's onBefore() and onComplete()

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Sep 27, 2016 at 4:11 PM, durairaj t  wrote:

> Based on the wicket 1.5 comments in IAjaxCallDecorator.java,
> I think, I may need to use "beforeSend" for "decorateScript" and
> "onSuccess" for "decorateOnSuccessScript".
>
> But I'm not sure.  Any help?
>
> *Code snippet from wicket 1.5  IAjaxCallDecorator.java*
>
> /**
> * Decorates the script that performs the ajax call
> *
> * @param component
> * @param script
> * @return decorated script
> */
> CharSequence decorateScript(Component component, CharSequence script);
>
> /**
> * Decorates the onSuccess handler script
> *
> * @param component
> * @param script
> * @return decorated onSuccess handler script
> */
> CharSequence decorateOnSuccessScript(Component component, CharSequence
> script);
>
> On Tue, Sep 27, 2016 at 8:54 AM, durairaj t 
> wrote:
>
> > Hi,
> >
> > I'm replacing "decorateScript(Component arg0,CharSequence script)" with
> > "AjaxRequestAttributes#getSuccessHandler(Component component)"
> > and
> > "decorateOnSuccessScript(Component arg0,CharSequence script)"  with
> > "AjaxRequestAttributes# onSuccess(."
> >
> >
> > *Is it correct?*
> >
> >
> >
> >
> > On Mon, Sep 26, 2016 at 4:35 PM, Tobias Soloschenko <
> > tobiassolosche...@googlemail.com> wrote:
> >
> >> Hi,
> >>
> >> I just googled for it:
> >>
> >> http://apache-wicket.1842946.n4.nabble.com/Migration-1-5-gt-
> >> 6-CancelEventIfNoAjaxDecorator-td4652609.html
> >>
> >> Hope this helps.
> >>
> >> kind regards
> >>
> >> Tobias
> >>
> >> > Am 26.09.2016 um 22:13 schrieb durairaj t :
> >> >
> >> > How to replace the "new CancelEventIfNoAjaxDecorator();" in  wicket 7
> >> > AjaxCallListener?
> >> >
> >> > Any help?
> >>
> >
> >
>


Re: AjaxCallListener

2016-09-27 Thread durairaj t
Based on the wicket 1.5 comments in IAjaxCallDecorator.java,
I think, I may need to use "beforeSend" for "decorateScript" and
"onSuccess" for "decorateOnSuccessScript".

But I'm not sure.  Any help?

*Code snippet from wicket 1.5  IAjaxCallDecorator.java*

/**
* Decorates the script that performs the ajax call
*
* @param component
* @param script
* @return decorated script
*/
CharSequence decorateScript(Component component, CharSequence script);

/**
* Decorates the onSuccess handler script
*
* @param component
* @param script
* @return decorated onSuccess handler script
*/
CharSequence decorateOnSuccessScript(Component component, CharSequence
script);

On Tue, Sep 27, 2016 at 8:54 AM, durairaj t  wrote:

> Hi,
>
> I'm replacing "decorateScript(Component arg0,CharSequence script)" with
> "AjaxRequestAttributes#getSuccessHandler(Component component)"
> and
> "decorateOnSuccessScript(Component arg0,CharSequence script)"  with
> "AjaxRequestAttributes# onSuccess(."
>
>
> *Is it correct?*
>
>
>
>
> On Mon, Sep 26, 2016 at 4:35 PM, Tobias Soloschenko <
> tobiassolosche...@googlemail.com> wrote:
>
>> Hi,
>>
>> I just googled for it:
>>
>> http://apache-wicket.1842946.n4.nabble.com/Migration-1-5-gt-
>> 6-CancelEventIfNoAjaxDecorator-td4652609.html
>>
>> Hope this helps.
>>
>> kind regards
>>
>> Tobias
>>
>> > Am 26.09.2016 um 22:13 schrieb durairaj t :
>> >
>> > How to replace the "new CancelEventIfNoAjaxDecorator();" in  wicket 7
>> > AjaxCallListener?
>> >
>> > Any help?
>>
>
>


Re: AjaxCallListener

2016-09-27 Thread durairaj t
Hi,

I'm replacing "decorateScript(Component arg0,CharSequence script)" with
"AjaxRequestAttributes#getSuccessHandler(Component component)"
and
"decorateOnSuccessScript(Component arg0,CharSequence script)"  with
"AjaxRequestAttributes# onSuccess(."


*Is it correct?*




On Mon, Sep 26, 2016 at 4:35 PM, Tobias Soloschenko <
tobiassolosche...@googlemail.com> wrote:

> Hi,
>
> I just googled for it:
>
> http://apache-wicket.1842946.n4.nabble.com/Migration-1-5-gt-6-
> CancelEventIfNoAjaxDecorator-td4652609.html
>
> Hope this helps.
>
> kind regards
>
> Tobias
>
> > Am 26.09.2016 um 22:13 schrieb durairaj t :
> >
> > How to replace the "new CancelEventIfNoAjaxDecorator();" in  wicket 7
> > AjaxCallListener?
> >
> > Any help?
>


Re: AjaxCallListener

2016-09-26 Thread durairaj t
Ya. I used AjaxRequestAttributes#setPreventDefault(true);

Thank you!

On Mon, Sep 26, 2016 at 4:35 PM, Tobias Soloschenko <
tobiassolosche...@googlemail.com> wrote:

> Hi,
>
> I just googled for it:
>
> http://apache-wicket.1842946.n4.nabble.com/Migration-1-5-gt-6-
> CancelEventIfNoAjaxDecorator-td4652609.html
>
> Hope this helps.
>
> kind regards
>
> Tobias
>
> > Am 26.09.2016 um 22:13 schrieb durairaj t :
> >
> > How to replace the "new CancelEventIfNoAjaxDecorator();" in  wicket 7
> > AjaxCallListener?
> >
> > Any help?
>


Re: AjaxCallListener

2016-09-26 Thread Tobias Soloschenko
Hi,

I just googled for it:

http://apache-wicket.1842946.n4.nabble.com/Migration-1-5-gt-6-CancelEventIfNoAjaxDecorator-td4652609.html

Hope this helps.

kind regards

Tobias

> Am 26.09.2016 um 22:13 schrieb durairaj t :
> 
> How to replace the "new CancelEventIfNoAjaxDecorator();" in  wicket 7
> AjaxCallListener?
> 
> Any help?


Re: AjaxCallListener and script of Component

2013-07-11 Thread Martin Grigorov
Hi,

Read
https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax#WicketAjax-o.a.w.ajax.IAjaxCallDecoratorisreplacedwitho.a.w.ajax.attributes.IAjaxCallListener.


On Thu, Jul 11, 2013 at 3:38 PM, Altuğ Bilgin Altıntaş alt...@gmail.comwrote:

 Hi all;

 We are trying to migrate from Wicket 1.4 to 6.9.0.

 We encountered a strange problem.

 Here is the migrated code (which is working incorrectly):

  @Override
 protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
 super.updateAjaxAttributes(attributes);

 AjaxCallListener myAjaxCallListener = new AjaxCallListener() {

 @Override
 public CharSequence getFailureHandler(Component component) {
 return BlockerBehaviour.getJSUnBlock();
 }

 @Override
 public CharSequence getBeforeHandler(Component component) {
   return BlockerBehaviour.getJSBlock();
 }

@Override
public CharSequence getSuccessHandler(Component component){
   return BlockerBehaviour.getJSUnBlock();
}
  };

 attributes.getAjaxCallListeners().add(myAjaxCallListener);
 }

 My application doesn't work because we need to add Component's script. I
 mean in Wicket 1.4 version , I can append component's script like this, ex
 :

 @Override
  public CharSequence decorateOnFailureScript(CharSequence script) {
 return *script *+   + BlockerBehaviour.getJSUnBlock();
 }

 How can we append script of Component in Wicket 6.9.0 ?

 Thanks.



Re: AjaxCallListener and script of Component

2013-07-11 Thread Altuğ Bilgin Altıntaş
Thanks.


On Thu, Jul 11, 2013 at 3:42 PM, Martin Grigorov mgrigo...@apache.orgwrote:

 Hi,

 Read

 https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax#WicketAjax-o.a.w.ajax.IAjaxCallDecoratorisreplacedwitho.a.w.ajax.attributes.IAjaxCallListener
 .


 On Thu, Jul 11, 2013 at 3:38 PM, Altuğ Bilgin Altıntaş alt...@gmail.com
 wrote:

  Hi all;
 
  We are trying to migrate from Wicket 1.4 to 6.9.0.
 
  We encountered a strange problem.
 
  Here is the migrated code (which is working incorrectly):
 
   @Override
  protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
  super.updateAjaxAttributes(attributes);
 
  AjaxCallListener myAjaxCallListener = new AjaxCallListener() {
 
  @Override
  public CharSequence getFailureHandler(Component component) {
  return BlockerBehaviour.getJSUnBlock();
  }
 
  @Override
  public CharSequence getBeforeHandler(Component component) {
return BlockerBehaviour.getJSBlock();
  }
 
 @Override
 public CharSequence getSuccessHandler(Component component)
  {
return BlockerBehaviour.getJSUnBlock();
 }
   };
 
  attributes.getAjaxCallListeners().add(myAjaxCallListener);
  }
 
  My application doesn't work because we need to add Component's script. I
  mean in Wicket 1.4 version , I can append component's script like this,
 ex
  :
 
  @Override
   public CharSequence decorateOnFailureScript(CharSequence script) {
  return *script *+   + BlockerBehaviour.getJSUnBlock();
  }
 
  How can we append script of Component in Wicket 6.9.0 ?
 
  Thanks.
 



Re: AjaxCallListener precondition with user input

2012-11-26 Thread Thomas Heigl
Hey Sekib,

Thanks a lot for your input!

In case anybody has a similar problem, I ended up solving it through an
AjaxCallListener with a little workaround. If the user confirms the alert,
I re-trigger a click on the link with additional data and check for that in
my precondition. This can be used to perform arbitrary async actions in a
listener precondition.

@Override
 public CharSequence getPrecondition(final Component component) {

return if (attrs.event.extraData != 'OK')  { jConfirm(function(r)
 { if (r) { $('# + component.getMarkupId() + ').trigger('click', 'OK'); }
 }); return false;;

}


Cheers,

Thomas

On Mon, Nov 5, 2012 at 2:35 PM, Sekib_Omazic sekib1...@gmail.com wrote:

 If this is an option for you, you could use modal dialog from twitter
 bootstrap (short example can be fond here:
 https://github.com/sekib/twittermodal). I don't use public CharSequence
 getPrecondition(final Component component) at all. Modal dialog is shown
 after clicking the link (no ajax call). Only a click on Of course button
 triggers an ajax call.



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/AjaxCallListener-precondition-with-user-input-tp4653566p4653622.html
 Sent from the Users forum mailing list archive at Nabble.com.

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




Re: AjaxCallListener precondition with user input

2012-11-05 Thread Sekib_Omazic
If this is an option for you, you could use modal dialog from twitter
bootstrap (short example can be fond here:
https://github.com/sekib/twittermodal). I don't use public CharSequence
getPrecondition(final Component component) at all. Modal dialog is shown
after clicking the link (no ajax call). Only a click on Of course button
triggers an ajax call.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AjaxCallListener-precondition-with-user-input-tp4653566p4653622.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: AjaxCallListener precondition with user input

2012-11-03 Thread Martin Grigorov
Hi,

Please create a quickstart and attach it to Jira.

On Fri, Nov 2, 2012 at 2:26 PM, Thomas Heigl tho...@umschalt.com wrote:
 Hey all,

 I'm currently in the progress of migrating a largish Wicket 1.5 app to
 Wicket 6.2. The only major problem I could not resolve so far are
 precondition scripts with user input.

 My old code looked like this:

@Override
 public CharSequence postDecorateScript(Component component, CharSequence
 script) {
 return jConfirm(function(r) { if (r) { + script + }});;
 }


 The whole script was decorated and the callback only executed if the user
 pressed OK in a custom confirmation dialog.

 In Wicket 6, there are no more script decorators, just listeners that
 provide hooks into the ajax lifecycle, so I changed my code to this:


  @Override
 public CharSequence getPrecondition(final Component component) {
 return jConfirm(function(r) { if (r) { return true; } }); return false;;
 }


 The problem is, that the callback function I'm passing to jConfirm is
 evaluated only when the user makes a selection, but the precondition has to
 return an output immediately. It would work if we used browser-level
 confirmation dialogs, but we use a custom jquery dialog for better user
 experience.

 Is there any way to emulate the pre-Wicket 6 behavior using listeners?

 Kind regards,

 Thomas



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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