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 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: Question about unit testing

2012-09-05 Thread Markward Schubert
Thanks for the link!

This is really interesting and I think I will adapt this.
Unfortunately I am not sure if this addresses my original Problem.

What I need is a kind of code, like this:

// start page...
tester.startComponentInPage(MyFormPanel.)

// verify that after initial page rendering, the selected item in the
DropDown equals the pageModel's
assertEquals(pageModel.myChoice.getLabel(),getDropDownChoice().currentlyRenderedSelectedChoiceItem());

As described before, I had a problem in the equals. This resulted in
myChoice being let's say red and the DropDown containing red black
blue, but please select was rendered in the DDC, because myChoice(red)
was not equal to dropChoice(red).

Sorry for the pseudo code :-)

So the DDC could not find out that the red of my model was the same as the
red in the choices list.
Of course this would be a stupid bug, but i would like to protect my code
against fellows changing the equals behavior.





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Question-about-unit-testing-tp4651766p4651768.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