Re: Migration to Wicket 6, updateAjaxAttributes

2013-09-24 Thread Martin Grigorov
Hi,

Check the generated JavaScript for this JS event binding in the page markup.
It should look like: Wicket.Ajax.ajax({})
Paste it here if you need help.

On Tue, Sep 24, 2013 at 8:21 PM, Markward Schubert 
markward.schub...@gmail.com wrote:

 Hi!

 I am not very experienced with Wicket and have to maintain an older project
 of ours.
 Now I wanted to migrate to Wicket 6 for a couple of reasons and had to
 change the behavior of a javascript-confirm before execute situation with
 an AjaxLink.

 add(new AjaxLinkString(clearContentLink) {

 private static final long serialVersionUID = 1L;

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

 IAjaxCallListener listener = new AjaxCallListener() {

 private static final long serialVersionUID = 1L;

 @Override
 public CharSequence getPrecondition(Component
 component) {
 return new JsonFunction(!confirm('Do you really


Here you miss return  in the function body.


 want to clear this logfile?'));
 }
 };

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

 @Override
 public void onClick(AjaxRequestTarget requestTarget) {
// clear here
 }
 });

 This above Link is added to a Panel (P2), which is created as a reaction to
 a click on another AjaxLink in another Panel (P1). P2 is wrapped in an
 AjaxLazyLoadPanel.

 The behavior I now observe is, that the confirm dialog is shown, when the
 P2, the one containing the link i wanted to enrich, is shown. When I click
 on the actual link, no confirm is shown. So speaking as a noob observer I
 would say, my AjaxCallListener was bound to some onShowLink event and not
 the onclick of the Link.

 Can anyone help?

 Thanks and Regards,
 Markward



Migration to Wicket 6, updateAjaxAttributes

2013-09-24 Thread Markward Schubert
Hi!

I am not very experienced with Wicket and have to maintain an older project
of ours.
Now I wanted to migrate to Wicket 6 for a couple of reasons and had to
change the behavior of a javascript-confirm before execute situation with
an AjaxLink.

add(new AjaxLinkString(clearContentLink) {

private static final long serialVersionUID = 1L;

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

IAjaxCallListener listener = new AjaxCallListener() {

private static final long serialVersionUID = 1L;

@Override
public CharSequence getPrecondition(Component
component) {
return new JsonFunction(!confirm('Do you really
want to clear this logfile?'));
}
};

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

@Override
public void onClick(AjaxRequestTarget requestTarget) {
   // clear here
}
});

This above Link is added to a Panel (P2), which is created as a reaction to
a click on another AjaxLink in another Panel (P1). P2 is wrapped in an
AjaxLazyLoadPanel.

The behavior I now observe is, that the confirm dialog is shown, when the
P2, the one containing the link i wanted to enrich, is shown. When I click
on the actual link, no confirm is shown. So speaking as a noob observer I
would say, my AjaxCallListener was bound to some onShowLink event and not
the onclick of the Link.

Can anyone help?

Thanks and Regards,
Markward


Re: Migration to Wicket 6, updateAjaxAttributes

2013-09-24 Thread Markward Schubert
Martin,


Hi,

 Check the generated JavaScript for this JS event binding in the page
 markup.
 It should look like: Wicket.Ajax.ajax({})
 Paste it here if you need help.

 On Tue, Sep 24, 2013 at 8:21 PM, Markward Schubert 
 markward.schub...@gmail.com wrote:

  Hi!
 
  I am not very experienced with Wicket and have to maintain an older
 project
  of ours.
  Now I wanted to migrate to Wicket 6 for a couple of reasons and had to
  change the behavior of a javascript-confirm before execute situation
 with
  an AjaxLink.
 
  add(new AjaxLinkString(clearContentLink) {
 
  private static final long serialVersionUID = 1L;
 
  @Override
  protected void updateAjaxAttributes(AjaxRequestAttributes
  attributes) {
  super.updateAjaxAttributes(attributes);
 
  IAjaxCallListener listener = new AjaxCallListener() {
 
  private static final long serialVersionUID = 1L;
 
  @Override
  public CharSequence getPrecondition(Component
  component) {
  return new JsonFunction(!confirm('Do you really
 

 Here you miss return  in the function body.


  want to clear this logfile?'));
  }
  };
 
  attributes.getAjaxCallListeners().add(listener);
  }
 
  @Override
  public void onClick(AjaxRequestTarget requestTarget) {
 // clear here
  }
  });
 
  This above Link is added to a Panel (P2), which is created as a reaction
 to
  a click on another AjaxLink in another Panel (P1). P2 is wrapped in an
  AjaxLazyLoadPanel.
 
  The behavior I now observe is, that the confirm dialog is shown, when the
  P2, the one containing the link i wanted to enrich, is shown. When I
 click
  on the actual link, no confirm is shown. So speaking as a noob
 observer I
  would say, my AjaxCallListener was bound to some onShowLink event and
 not
  the onclick of the Link.
 
  Can anyone help?
 
  Thanks and Regards,
  Markward
 



This is what I could extract from the site:

script type=text/javascript /*![CDATA[*/Wicket.Event.add(window,
domready, function(event) {
Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-0-link,e:click,c:link1});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-1-link,e:click,c:link2});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-2-link,e:click,c:link3});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-3-link,e:click,c:link4});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-panel,c:panel5});;;});/*]]*//script


Re: Migration to Wicket 6, updateAjaxAttributes

2013-09-24 Thread Martin Grigorov
There is no confirm word inside this JS code...
It seems your component is not loaded yet. If it is loaded later with Ajax
then you have to find it in the Ajax response. Use Firebug or similar tool
to do this.


On Tue, Sep 24, 2013 at 8:39 PM, Markward Schubert 
markward.schub...@gmail.com wrote:

 Martin,


 Hi,
 
  Check the generated JavaScript for this JS event binding in the page
  markup.
  It should look like: Wicket.Ajax.ajax({})
  Paste it here if you need help.
 
  On Tue, Sep 24, 2013 at 8:21 PM, Markward Schubert 
  markward.schub...@gmail.com wrote:
 
   Hi!
  
   I am not very experienced with Wicket and have to maintain an older
  project
   of ours.
   Now I wanted to migrate to Wicket 6 for a couple of reasons and had to
   change the behavior of a javascript-confirm before execute situation
  with
   an AjaxLink.
  
   add(new AjaxLinkString(clearContentLink) {
  
   private static final long serialVersionUID = 1L;
  
   @Override
   protected void updateAjaxAttributes(AjaxRequestAttributes
   attributes) {
   super.updateAjaxAttributes(attributes);
  
   IAjaxCallListener listener = new AjaxCallListener() {
  
   private static final long serialVersionUID = 1L;
  
   @Override
   public CharSequence getPrecondition(Component
   component) {
   return new JsonFunction(!confirm('Do you
 really
  
 
  Here you miss return  in the function body.
 
 
   want to clear this logfile?'));
   }
   };
  
   attributes.getAjaxCallListeners().add(listener);
   }
  
   @Override
   public void onClick(AjaxRequestTarget requestTarget) {
  // clear here
   }
   });
  
   This above Link is added to a Panel (P2), which is created as a
 reaction
  to
   a click on another AjaxLink in another Panel (P1). P2 is wrapped in an
   AjaxLazyLoadPanel.
  
   The behavior I now observe is, that the confirm dialog is shown, when
 the
   P2, the one containing the link i wanted to enrich, is shown. When I
  click
   on the actual link, no confirm is shown. So speaking as a noob
  observer I
   would say, my AjaxCallListener was bound to some onShowLink event and
  not
   the onclick of the Link.
  
   Can anyone help?
  
   Thanks and Regards,
   Markward
  
 


 This is what I could extract from the site:

 script type=text/javascript /*![CDATA[*/Wicket.Event.add(window,
 domready, function(event) {

 Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-0-link,e:click,c:link1});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-1-link,e:click,c:link2});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-2-link,e:click,c:link3});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-3-link,e:click,c:link4});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-panel,c:panel5});;;});/*]]*//script



Re: Migration to Wicket 6, updateAjaxAttributes

2013-09-24 Thread Markward Schubert
2013/9/24 Martin Grigorov mgrigo...@apache.org

 There is no confirm word inside this JS code...
 It seems your component is not loaded yet. If it is loaded later with Ajax
 then you have to find it in the Ajax response. Use Firebug or similar tool
 to do this.


 On Tue, Sep 24, 2013 at 8:39 PM, Markward Schubert 
 markward.schub...@gmail.com wrote:

  Martin,
 
 
  Hi,
  
   Check the generated JavaScript for this JS event binding in the page
   markup.
   It should look like: Wicket.Ajax.ajax({})
   Paste it here if you need help.
  
   On Tue, Sep 24, 2013 at 8:21 PM, Markward Schubert 
   markward.schub...@gmail.com wrote:
  
Hi!
   
I am not very experienced with Wicket and have to maintain an older
   project
of ours.
Now I wanted to migrate to Wicket 6 for a couple of reasons and had
 to
change the behavior of a javascript-confirm before execute
 situation
   with
an AjaxLink.
   
add(new AjaxLinkString(clearContentLink) {
   
private static final long serialVersionUID = 1L;
   
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes
attributes) {
super.updateAjaxAttributes(attributes);
   
IAjaxCallListener listener = new AjaxCallListener() {
   
private static final long serialVersionUID = 1L;
   
@Override
public CharSequence getPrecondition(Component
component) {
return new JsonFunction(!confirm('Do you
  really
   
  
   Here you miss return  in the function body.
  
  
want to clear this logfile?'));
}
};
   
attributes.getAjaxCallListeners().add(listener);
}
   
@Override
public void onClick(AjaxRequestTarget requestTarget) {
   // clear here
}
});
   
This above Link is added to a Panel (P2), which is created as a
  reaction
   to
a click on another AjaxLink in another Panel (P1). P2 is wrapped in
 an
AjaxLazyLoadPanel.
   
The behavior I now observe is, that the confirm dialog is shown, when
  the
P2, the one containing the link i wanted to enrich, is shown. When I
   click
on the actual link, no confirm is shown. So speaking as a noob
   observer I
would say, my AjaxCallListener was bound to some onShowLink event
 and
   not
the onclick of the Link.
   
Can anyone help?
   
Thanks and Regards,
Markward
   
  
 
 
  This is what I could extract from the site:
 
  script type=text/javascript /*![CDATA[*/Wicket.Event.add(window,
  domready, function(event) {
 
 
 Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-0-link,e:click,c:link1});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-1-link,e:click,c:link2});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-2-link,e:click,c:link3});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-3-link,e:click,c:link4});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-panel,c:panel5});;;});/*]]*//script
 


Ok, sorry for being so dumb :-)

Here we go:

![CDATA[(function(){Wicket.Ajax.ajax({u:./.?1-1.IBehaviorListener.0-mainPanel-tabs-panel-content-logcontent-content-clearContentLink,e:click,c:clearContentLink57,pre:[!confirm('Do
you really want to clear this logfile?')]^});})();]]

This is part of the second of two GET requests, being protocolled in
Firebug's console when I click on a Link in Panel P1. I assume these two
happen because of P2 being loaded as the content of a lazy loaded Panel?


Re: Migration to Wicket 6, updateAjaxAttributes

2013-09-24 Thread Martin Grigorov
On Tue, Sep 24, 2013 at 9:04 PM, Markward Schubert 
markward.schub...@gmail.com wrote:

 2013/9/24 Martin Grigorov mgrigo...@apache.org

  There is no confirm word inside this JS code...
  It seems your component is not loaded yet. If it is loaded later with
 Ajax
  then you have to find it in the Ajax response. Use Firebug or similar
 tool
  to do this.
 
 
  On Tue, Sep 24, 2013 at 8:39 PM, Markward Schubert 
  markward.schub...@gmail.com wrote:
 
   Martin,
  
  
   Hi,
   
Check the generated JavaScript for this JS event binding in the page
markup.
It should look like: Wicket.Ajax.ajax({})
Paste it here if you need help.
   
On Tue, Sep 24, 2013 at 8:21 PM, Markward Schubert 
markward.schub...@gmail.com wrote:
   
 Hi!

 I am not very experienced with Wicket and have to maintain an older
project
 of ours.
 Now I wanted to migrate to Wicket 6 for a couple of reasons and had
  to
 change the behavior of a javascript-confirm before execute
  situation
with
 an AjaxLink.

 add(new AjaxLinkString(clearContentLink) {

 private static final long serialVersionUID = 1L;

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

 IAjaxCallListener listener = new
 AjaxCallListener() {

 private static final long serialVersionUID =
 1L;

 @Override
 public CharSequence getPrecondition(Component
 component) {
 return new JsonFunction(!confirm('Do you
   really

   
Here you miss return  in the function body.
   
   
 want to clear this logfile?'));
 }
 };

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

 @Override
 public void onClick(AjaxRequestTarget requestTarget) {
// clear here
 }
 });

 This above Link is added to a Panel (P2), which is created as a
   reaction
to
 a click on another AjaxLink in another Panel (P1). P2 is wrapped in
  an
 AjaxLazyLoadPanel.

 The behavior I now observe is, that the confirm dialog is shown,
 when
   the
 P2, the one containing the link i wanted to enrich, is shown. When
 I
click
 on the actual link, no confirm is shown. So speaking as a noob
observer I
 would say, my AjaxCallListener was bound to some onShowLink event
  and
not
 the onclick of the Link.

 Can anyone help?

 Thanks and Regards,
 Markward

   
  
  
   This is what I could extract from the site:
  
   script type=text/javascript /*![CDATA[*/Wicket.Event.add(window,
   domready, function(event) {
  
  
 
 Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-0-link,e:click,c:link1});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-1-link,e:click,c:link2});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-2-link,e:click,c:link3});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-tabs~container-tabs-3-link,e:click,c:link4});;Wicket.Ajax.ajax({u:./?0-1.IBehaviorListener.0-mainPanel-tabs-panel,c:panel5});;;});/*]]*//script
  
 

 Ok, sorry for being so dumb :-)

 Here we go:


 ![CDATA[(function(){Wicket.Ajax.ajax({u:./.?1-1.IBehaviorListener.0-mainPanel-tabs-panel-content-logcontent-content-clearContentLink,e:click,c:clearContentLink57,pre:[!confirm('Do
 you really want to clear this logfile?')]^});})();]]

 This is part of the second of two GET requests, being protocolled in
 Firebug's console when I click on a Link in Panel P1. I assume these two
 happen because of P2 being loaded as the content of a lazy loaded Panel?


Right.

As you can see the generated JS is not what you want.

Simple fix is to return the following String:
@Override
public CharSequence getPrecondition(Component component) {
  return return !confirm('Do you really want to clear this logfile?'));
}

See the difference between returning JsonFunction and any other
CharSequence at
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java?source=cc#L387


migration to wicket 6

2012-11-09 Thread saty
old wicket code has this everywhere in my app
some textField .add

new AjaxEventBehavior(onkeypress)
{
.
.

protected CharSequence getCallbackScript(boolean onlyTargetActivePage)
{

}
.
.
}

could someone point me to an example how this can be done in wicket 6.
Looking to migrate getCallbackScript(boolean onlyTargetActivePage) part.

Thanks




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/migration-to-wicket-6-tp4653756.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: migration to wicket 6

2012-11-09 Thread Sven Meier
I'm not sure what you're doing in #getCallbackScript() but have you read 
this?


https://cwiki.apache.org/WICKET/wicket-ajax.html#WicketAjax-AjaxRequestAttributes

Sven

On 11/09/2012 09:25 PM, saty wrote:

old wicket code has this everywhere in my app
some textField .add

new AjaxEventBehavior(onkeypress)
{
.
.

protected CharSequence getCallbackScript(boolean onlyTargetActivePage)
{

}
.
.
}

could someone point me to an example how this can be done in wicket 6.
Looking to migrate getCallbackScript(boolean onlyTargetActivePage) part.

Thanks




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/migration-to-wicket-6-tp4653756.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




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



Re: migration to wicket 6

2012-11-09 Thread Martin Grigorov
Read about dynamic extra parameters in the link that Sven gave you earlier.


On Fri, Nov 9, 2012 at 11:05 PM, saty satya...@gmail.com wrote:

 Thanks, its pretty much doing something similar to this example



 https://cwiki.apache.org/WICKET/identifying-the-key-that-was-pressed-in-a-serverside-key-handler.html



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/migration-to-wicket-6-tp4653756p4653758.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




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