Re: Get return value of ajax event in Wicket 6.9.1

2013-11-14 Thread Daniela L
Hi,
now everything works perfect,
thank you I am so happy.
Best Regards
Daniela


2013/11/14 Martin Grigorov mgrigo...@apache.org

 Hi,

 mySubmitButton.add(AttributeAppender.append(onclick, window.dontAsk =
 true; return true;))

 response.render(new
 OnDomReadyHeaderItem(window.onbeforeunload = function (e) {
   + if (!window.dontAsk) { +
   + var message = 'Your confirmation message goes
 here.',
   + e = e || window.event; + if (e) {
   + e.returnValue = message; + } + return
 message;
+ }
 + };));


 On Wed, Nov 13, 2013 at 4:12 PM, Daniela L danigal...@gmail.com wrote:

  Hi,
  I am sorry I don't get it.
  How and when to set the JS variable?
  Like this:
  mySubmitButton.add(new AjaxEventBehavior(onclick) {
  @Override
  protected void onEvent(AjaxRequestTarget target) {
  AjaxRequestAttributes ajaxRequestAttributes = new
  AjaxRequestAttributes();
  CharSequence dynamicExtraParameters = var enableEvent =
  false;;
 
 
 
 
 ajaxRequestAttributes.getDynamicExtraParameters().add(dynamicExtraParameters)
 
  pageExitWarningBehavior.updateAjaxAttributes(ajaxRequestAttributes);
  }
  });
 
  And which onBeforeRender, the one of the TextField?
  Best Regards
  Daniela
 
 
  2013/11/13 Martin Grigorov mgrigo...@apache.org
 
   Hi,
  
   #onSubmit() would be called after the user agrees to leave the page.
  
   You can set some JS variable/flag when the submit button is used and
   depending on this flag do not ask for confirmation in onbeforerender.
  
  
   On Wed, Nov 13, 2013 at 10:02 AM, Daniela L danigal...@gmail.com
  wrote:
  
Hi,
I have another problem regarding this question.
Now every time the page is left the message  Do you want to leave
 the
page is popping up,
but when the user correctly fills the form on the page and hits the
   submit
button
he should be redirected to another page showing the result of his
  input.
I have tryed this to remove the behavior for a correct submit but the
message is still popping up:
   
mySubmitButton = new Button(mySubmitButton ) {
   
@Override
public void onSubmit() {
try {
myTextField.remove(pageExitWarningBehavior);
//tryed both
//pageExitWarningBehavior.detach(myTextField);
   }
};
   
   
2013/11/12 Daniela L danigal...@gmail.com
   
 Hi,
 thank you so much for your help this works fantastic.
 I am so happy I was trying around with this for days :-)


 2013/11/11 Martin Grigorov mgrigo...@apache.org

 respond() is the callback method that Wicket will notify.
 But you need to trigger an Ajax call first. This is done with the
   Wicket
 Ajax API: Wicket.Ajax.get(...).

 Just try with the line I've added in your JS code


 On Mon, Nov 11, 2013 at 4:04 PM, Daniela L danigal...@gmail.com
wrote:

  I thought adding respond was the ajax call to the server, am I
   wrong?
  I didn't work much with ajax, i am sorry
 
 
  2013/11/11 Martin Grigorov mgrigo...@apache.org
 
   Did you do what I suggested you ?
  
  
   On Mon, Nov 11, 2013 at 3:49 PM, Daniela L 
  danigal...@gmail.com
 wrote:
  
Hi,
   
I have tryed to change to AbstractDefaultAjaxBehavior like I
 described
below, but respond is never called. What am I doing wrong?
   
   
Hi,
   
as far as I have understood this can only be achieved, if I
subclass
AbstractDefaultAjaxBehavior like this?
   
public class PageExitWarningBehavior extends
  AbstractDefaultAjaxBehavior
{
@Override
protected void respond(AjaxRequestTarget target) {
   
   
  AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
  }
   
   
Hi,
   
You need to make an Ajax call to the server.
   
   
On Mon, Nov 11, 2013 at 2:10 PM, Daniela L 
   danigal...@gmail.com
danigal...@gmail.comdanigal...@gmail.com 
danigal...@gmail.com
wrote:
   
   
Hi,
this is my first question, so i hope I get everything right.
   
I am trying to catch the event of the user closing the
 browser
 window
  in
wicket.
   
I followed this example:
   
   
  
 

   
  
 
 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value
   
and I managed to get the example working so the message is
 displayed,
   but I
have no idea how to get the event triggered by the
 javascript
 function
  in
wicket. I need this because when the user 

Re: Get return value of ajax event in Wicket 6.9.1

2013-11-13 Thread Daniela L
Hi,
I have another problem regarding this question.
Now every time the page is left the message  Do you want to leave the
page is popping up,
but when the user correctly fills the form on the page and hits the submit
button
he should be redirected to another page showing the result of his input.
I have tryed this to remove the behavior for a correct submit but the
message is still popping up:

mySubmitButton = new Button(mySubmitButton ) {

@Override
public void onSubmit() {
try {
myTextField.remove(pageExitWarningBehavior);
//tryed both
//pageExitWarningBehavior.detach(myTextField);
   }
};


2013/11/12 Daniela L danigal...@gmail.com

 Hi,
 thank you so much for your help this works fantastic.
 I am so happy I was trying around with this for days :-)


 2013/11/11 Martin Grigorov mgrigo...@apache.org

 respond() is the callback method that Wicket will notify.
 But you need to trigger an Ajax call first. This is done with the Wicket
 Ajax API: Wicket.Ajax.get(...).

 Just try with the line I've added in your JS code


 On Mon, Nov 11, 2013 at 4:04 PM, Daniela L danigal...@gmail.com wrote:

  I thought adding respond was the ajax call to the server, am I wrong?
  I didn't work much with ajax, i am sorry
 
 
  2013/11/11 Martin Grigorov mgrigo...@apache.org
 
   Did you do what I suggested you ?
  
  
   On Mon, Nov 11, 2013 at 3:49 PM, Daniela L danigal...@gmail.com
 wrote:
  
Hi,
   
I have tryed to change to AbstractDefaultAjaxBehavior like I
 described
below, but respond is never called. What am I doing wrong?
   
   
Hi,
   
as far as I have understood this can only be achieved, if I subclass
AbstractDefaultAjaxBehavior like this?
   
public class PageExitWarningBehavior extends
  AbstractDefaultAjaxBehavior
{
@Override
protected void respond(AjaxRequestTarget target) {
   
AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
  }
   
   
Hi,
   
You need to make an Ajax call to the server.
   
   
On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com
danigal...@gmail.comdanigal...@gmail.com danigal...@gmail.com
wrote:
   
   
Hi,
this is my first question, so i hope I get everything right.
   
I am trying to catch the event of the user closing the browser
 window
  in
wicket.
   
I followed this example:
   
   
  
 
 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value
   
and I managed to get the example working so the message is
 displayed,
   but I
have no idea how to get the event triggered by the javascript
 function
  in
wicket. I need this because when the user closes the browser window
 I
   want
to update some data in my database.
Here is what I have tryed:
   
   
 RequiredTextFieldString myTextField = new
RequiredTextFieldString(myTextField);
 myTextField.setOutputMarkupPlaceholderTag(true);
 myTextField.add(new PageExitWarningBehavior(){
@Override
public void onEvent(Component component, IEvent?
 event)
{
//this isn't ever called
MySession.get().releaseBlockedDataFromDatabase();
}
});
   
public class PageExitWarningBehavior extends Behavior  {
@Override
public void renderHead(Component component, IHeaderResponse
response) {
super.renderHead(component, response);
response.render(new
OnDomReadyHeaderItem(window.onbeforeunload = function (e) {
   
   
  + Wicket.Ajax.get({u: '+getCallbackUrl()+',
   async:
false});
   
   
  + var message = 'Your confirmation message goes
here.',
   
  + e = e || window.event; + if (e) {
   
  + e.returnValue = message; + } + return
  message;
   +
};));
}
}
   
What am I missing? Thank you very much in advance
   
  
 





Re: Get return value of ajax event in Wicket 6.9.1

2013-11-13 Thread Martin Grigorov
Hi,

#onSubmit() would be called after the user agrees to leave the page.

You can set some JS variable/flag when the submit button is used and
depending on this flag do not ask for confirmation in onbeforerender.


On Wed, Nov 13, 2013 at 10:02 AM, Daniela L danigal...@gmail.com wrote:

 Hi,
 I have another problem regarding this question.
 Now every time the page is left the message  Do you want to leave the
 page is popping up,
 but when the user correctly fills the form on the page and hits the submit
 button
 he should be redirected to another page showing the result of his input.
 I have tryed this to remove the behavior for a correct submit but the
 message is still popping up:

 mySubmitButton = new Button(mySubmitButton ) {

 @Override
 public void onSubmit() {
 try {
 myTextField.remove(pageExitWarningBehavior);
 //tryed both
 //pageExitWarningBehavior.detach(myTextField);
}
 };


 2013/11/12 Daniela L danigal...@gmail.com

  Hi,
  thank you so much for your help this works fantastic.
  I am so happy I was trying around with this for days :-)
 
 
  2013/11/11 Martin Grigorov mgrigo...@apache.org
 
  respond() is the callback method that Wicket will notify.
  But you need to trigger an Ajax call first. This is done with the Wicket
  Ajax API: Wicket.Ajax.get(...).
 
  Just try with the line I've added in your JS code
 
 
  On Mon, Nov 11, 2013 at 4:04 PM, Daniela L danigal...@gmail.com
 wrote:
 
   I thought adding respond was the ajax call to the server, am I wrong?
   I didn't work much with ajax, i am sorry
  
  
   2013/11/11 Martin Grigorov mgrigo...@apache.org
  
Did you do what I suggested you ?
   
   
On Mon, Nov 11, 2013 at 3:49 PM, Daniela L danigal...@gmail.com
  wrote:
   
 Hi,

 I have tryed to change to AbstractDefaultAjaxBehavior like I
  described
 below, but respond is never called. What am I doing wrong?


 Hi,

 as far as I have understood this can only be achieved, if I
 subclass
 AbstractDefaultAjaxBehavior like this?

 public class PageExitWarningBehavior extends
   AbstractDefaultAjaxBehavior
 {
 @Override
 protected void respond(AjaxRequestTarget target) {

 AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
   }


 Hi,

 You need to make an Ajax call to the server.


 On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com
 danigal...@gmail.comdanigal...@gmail.com 
 danigal...@gmail.com
 wrote:


 Hi,
 this is my first question, so i hope I get everything right.

 I am trying to catch the event of the user closing the browser
  window
   in
 wicket.

 I followed this example:


   
  
 
 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value

 and I managed to get the example working so the message is
  displayed,
but I
 have no idea how to get the event triggered by the javascript
  function
   in
 wicket. I need this because when the user closes the browser
 window
  I
want
 to update some data in my database.
 Here is what I have tryed:


  RequiredTextFieldString myTextField = new
 RequiredTextFieldString(myTextField);
  myTextField.setOutputMarkupPlaceholderTag(true);
  myTextField.add(new PageExitWarningBehavior(){
 @Override
 public void onEvent(Component component, IEvent?
  event)
 {
 //this isn't ever called
 MySession.get().releaseBlockedDataFromDatabase();
 }
 });

 public class PageExitWarningBehavior extends Behavior  {
 @Override
 public void renderHead(Component component,
 IHeaderResponse
 response) {
 super.renderHead(component, response);
 response.render(new
 OnDomReadyHeaderItem(window.onbeforeunload = function (e) {


   + Wicket.Ajax.get({u:
 '+getCallbackUrl()+',
async:
 false});


   + var message = 'Your confirmation message goes
 here.',

   + e = e || window.event; + if (e) {

   + e.returnValue = message; + } + return
   message;
+
 };));
 }
 }

 What am I missing? Thank you very much in advance

   
  
 
 
 



Re: Get return value of ajax event in Wicket 6.9.1

2013-11-13 Thread Daniela L
Hi,
I am sorry I don't get it.
How and when to set the JS variable?
Like this:
mySubmitButton.add(new AjaxEventBehavior(onclick) {
@Override
protected void onEvent(AjaxRequestTarget target) {
AjaxRequestAttributes ajaxRequestAttributes = new
AjaxRequestAttributes();
CharSequence dynamicExtraParameters = var enableEvent =
false;;


ajaxRequestAttributes.getDynamicExtraParameters().add(dynamicExtraParameters)

pageExitWarningBehavior.updateAjaxAttributes(ajaxRequestAttributes);
}
});

And which onBeforeRender, the one of the TextField?
Best Regards
Daniela


2013/11/13 Martin Grigorov mgrigo...@apache.org

 Hi,

 #onSubmit() would be called after the user agrees to leave the page.

 You can set some JS variable/flag when the submit button is used and
 depending on this flag do not ask for confirmation in onbeforerender.


 On Wed, Nov 13, 2013 at 10:02 AM, Daniela L danigal...@gmail.com wrote:

  Hi,
  I have another problem regarding this question.
  Now every time the page is left the message  Do you want to leave the
  page is popping up,
  but when the user correctly fills the form on the page and hits the
 submit
  button
  he should be redirected to another page showing the result of his input.
  I have tryed this to remove the behavior for a correct submit but the
  message is still popping up:
 
  mySubmitButton = new Button(mySubmitButton ) {
 
  @Override
  public void onSubmit() {
  try {
  myTextField.remove(pageExitWarningBehavior);
  //tryed both
  //pageExitWarningBehavior.detach(myTextField);
 }
  };
 
 
  2013/11/12 Daniela L danigal...@gmail.com
 
   Hi,
   thank you so much for your help this works fantastic.
   I am so happy I was trying around with this for days :-)
  
  
   2013/11/11 Martin Grigorov mgrigo...@apache.org
  
   respond() is the callback method that Wicket will notify.
   But you need to trigger an Ajax call first. This is done with the
 Wicket
   Ajax API: Wicket.Ajax.get(...).
  
   Just try with the line I've added in your JS code
  
  
   On Mon, Nov 11, 2013 at 4:04 PM, Daniela L danigal...@gmail.com
  wrote:
  
I thought adding respond was the ajax call to the server, am I
 wrong?
I didn't work much with ajax, i am sorry
   
   
2013/11/11 Martin Grigorov mgrigo...@apache.org
   
 Did you do what I suggested you ?


 On Mon, Nov 11, 2013 at 3:49 PM, Daniela L danigal...@gmail.com
   wrote:

  Hi,
 
  I have tryed to change to AbstractDefaultAjaxBehavior like I
   described
  below, but respond is never called. What am I doing wrong?
 
 
  Hi,
 
  as far as I have understood this can only be achieved, if I
  subclass
  AbstractDefaultAjaxBehavior like this?
 
  public class PageExitWarningBehavior extends
AbstractDefaultAjaxBehavior
  {
  @Override
  protected void respond(AjaxRequestTarget target) {
 
  AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
}
 
 
  Hi,
 
  You need to make an Ajax call to the server.
 
 
  On Mon, Nov 11, 2013 at 2:10 PM, Daniela L 
 danigal...@gmail.com
  danigal...@gmail.comdanigal...@gmail.com 
  danigal...@gmail.com
  wrote:
 
 
  Hi,
  this is my first question, so i hope I get everything right.
 
  I am trying to catch the event of the user closing the browser
   window
in
  wicket.
 
  I followed this example:
 
 

   
  
 
 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value
 
  and I managed to get the example working so the message is
   displayed,
 but I
  have no idea how to get the event triggered by the javascript
   function
in
  wicket. I need this because when the user closes the browser
  window
   I
 want
  to update some data in my database.
  Here is what I have tryed:
 
 
   RequiredTextFieldString myTextField = new
  RequiredTextFieldString(myTextField);
   myTextField.setOutputMarkupPlaceholderTag(true);
   myTextField.add(new PageExitWarningBehavior(){
  @Override
  public void onEvent(Component component, IEvent?
   event)
  {
  //this isn't ever called
 
 MySession.get().releaseBlockedDataFromDatabase();
  }
  });
 
  public class PageExitWarningBehavior extends Behavior  {
  @Override
  public void renderHead(Component component,
  IHeaderResponse
  response) {
  super.renderHead(component, response);
  response.render(new
  OnDomReadyHeaderItem(window.onbeforeunload = function (e) {
 
 
  

Re: Get return value of ajax event in Wicket 6.9.1

2013-11-13 Thread Martin Grigorov
Hi,

mySubmitButton.add(AttributeAppender.append(onclick, window.dontAsk =
true; return true;))

response.render(new
OnDomReadyHeaderItem(window.onbeforeunload = function (e) {
  + if (!window.dontAsk) { +
  + var message = 'Your confirmation message goes
here.',
  + e = e || window.event; + if (e) {
  + e.returnValue = message; + } + return message;
   + }
+ };));


On Wed, Nov 13, 2013 at 4:12 PM, Daniela L danigal...@gmail.com wrote:

 Hi,
 I am sorry I don't get it.
 How and when to set the JS variable?
 Like this:
 mySubmitButton.add(new AjaxEventBehavior(onclick) {
 @Override
 protected void onEvent(AjaxRequestTarget target) {
 AjaxRequestAttributes ajaxRequestAttributes = new
 AjaxRequestAttributes();
 CharSequence dynamicExtraParameters = var enableEvent =
 false;;



 ajaxRequestAttributes.getDynamicExtraParameters().add(dynamicExtraParameters)

 pageExitWarningBehavior.updateAjaxAttributes(ajaxRequestAttributes);
 }
 });

 And which onBeforeRender, the one of the TextField?
 Best Regards
 Daniela


 2013/11/13 Martin Grigorov mgrigo...@apache.org

  Hi,
 
  #onSubmit() would be called after the user agrees to leave the page.
 
  You can set some JS variable/flag when the submit button is used and
  depending on this flag do not ask for confirmation in onbeforerender.
 
 
  On Wed, Nov 13, 2013 at 10:02 AM, Daniela L danigal...@gmail.com
 wrote:
 
   Hi,
   I have another problem regarding this question.
   Now every time the page is left the message  Do you want to leave the
   page is popping up,
   but when the user correctly fills the form on the page and hits the
  submit
   button
   he should be redirected to another page showing the result of his
 input.
   I have tryed this to remove the behavior for a correct submit but the
   message is still popping up:
  
   mySubmitButton = new Button(mySubmitButton ) {
  
   @Override
   public void onSubmit() {
   try {
   myTextField.remove(pageExitWarningBehavior);
   //tryed both
   //pageExitWarningBehavior.detach(myTextField);
  }
   };
  
  
   2013/11/12 Daniela L danigal...@gmail.com
  
Hi,
thank you so much for your help this works fantastic.
I am so happy I was trying around with this for days :-)
   
   
2013/11/11 Martin Grigorov mgrigo...@apache.org
   
respond() is the callback method that Wicket will notify.
But you need to trigger an Ajax call first. This is done with the
  Wicket
Ajax API: Wicket.Ajax.get(...).
   
Just try with the line I've added in your JS code
   
   
On Mon, Nov 11, 2013 at 4:04 PM, Daniela L danigal...@gmail.com
   wrote:
   
 I thought adding respond was the ajax call to the server, am I
  wrong?
 I didn't work much with ajax, i am sorry


 2013/11/11 Martin Grigorov mgrigo...@apache.org

  Did you do what I suggested you ?
 
 
  On Mon, Nov 11, 2013 at 3:49 PM, Daniela L 
 danigal...@gmail.com
wrote:
 
   Hi,
  
   I have tryed to change to AbstractDefaultAjaxBehavior like I
described
   below, but respond is never called. What am I doing wrong?
  
  
   Hi,
  
   as far as I have understood this can only be achieved, if I
   subclass
   AbstractDefaultAjaxBehavior like this?
  
   public class PageExitWarningBehavior extends
 AbstractDefaultAjaxBehavior
   {
   @Override
   protected void respond(AjaxRequestTarget target) {
  
  
 AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
 }
  
  
   Hi,
  
   You need to make an Ajax call to the server.
  
  
   On Mon, Nov 11, 2013 at 2:10 PM, Daniela L 
  danigal...@gmail.com
   danigal...@gmail.comdanigal...@gmail.com 
   danigal...@gmail.com
   wrote:
  
  
   Hi,
   this is my first question, so i hope I get everything right.
  
   I am trying to catch the event of the user closing the browser
window
 in
   wicket.
  
   I followed this example:
  
  
 

   
  
 
 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value
  
   and I managed to get the example working so the message is
displayed,
  but I
   have no idea how to get the event triggered by the javascript
function
 in
   wicket. I need this because when the user closes the browser
   window
I
  want
   to update some data in my database.
   Here is what I have tryed:
  
  
RequiredTextFieldString myTextField = new
   RequiredTextFieldString(myTextField);
myTextField.setOutputMarkupPlaceholderTag(true);

Re: Get return value of ajax event in Wicket 6.9.1

2013-11-12 Thread Daniela L
Hi,
thank you so much for your help this works fantastic.
I am so happy I was trying around with this for days :-)


2013/11/11 Martin Grigorov mgrigo...@apache.org

 respond() is the callback method that Wicket will notify.
 But you need to trigger an Ajax call first. This is done with the Wicket
 Ajax API: Wicket.Ajax.get(...).

 Just try with the line I've added in your JS code


 On Mon, Nov 11, 2013 at 4:04 PM, Daniela L danigal...@gmail.com wrote:

  I thought adding respond was the ajax call to the server, am I wrong?
  I didn't work much with ajax, i am sorry
 
 
  2013/11/11 Martin Grigorov mgrigo...@apache.org
 
   Did you do what I suggested you ?
  
  
   On Mon, Nov 11, 2013 at 3:49 PM, Daniela L danigal...@gmail.com
 wrote:
  
Hi,
   
I have tryed to change to AbstractDefaultAjaxBehavior like I
 described
below, but respond is never called. What am I doing wrong?
   
   
Hi,
   
as far as I have understood this can only be achieved, if I subclass
AbstractDefaultAjaxBehavior like this?
   
public class PageExitWarningBehavior extends
  AbstractDefaultAjaxBehavior
{
@Override
protected void respond(AjaxRequestTarget target) {
   
AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
  }
   
   
Hi,
   
You need to make an Ajax call to the server.
   
   
On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com
danigal...@gmail.comdanigal...@gmail.com danigal...@gmail.com
wrote:
   
   
Hi,
this is my first question, so i hope I get everything right.
   
I am trying to catch the event of the user closing the browser window
  in
wicket.
   
I followed this example:
   
   
  
 
 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value
   
and I managed to get the example working so the message is displayed,
   but I
have no idea how to get the event triggered by the javascript
 function
  in
wicket. I need this because when the user closes the browser window I
   want
to update some data in my database.
Here is what I have tryed:
   
   
 RequiredTextFieldString myTextField = new
RequiredTextFieldString(myTextField);
 myTextField.setOutputMarkupPlaceholderTag(true);
 myTextField.add(new PageExitWarningBehavior(){
@Override
public void onEvent(Component component, IEvent? event)
{
//this isn't ever called
MySession.get().releaseBlockedDataFromDatabase();
}
});
   
public class PageExitWarningBehavior extends Behavior  {
@Override
public void renderHead(Component component, IHeaderResponse
response) {
super.renderHead(component, response);
response.render(new
OnDomReadyHeaderItem(window.onbeforeunload = function (e) {
   
   
  + Wicket.Ajax.get({u: '+getCallbackUrl()+',
   async:
false});
   
   
  + var message = 'Your confirmation message goes
here.',
   
  + e = e || window.event; + if (e) {
   
  + e.returnValue = message; + } + return
  message;
   +
};));
}
}
   
What am I missing? Thank you very much in advance
   
  
 



Get return value of ajax event in Wicket 6.9.1

2013-11-11 Thread Daniela L
Hi,
this is my first question, so i hope I get everything right.

I am trying to catch the event of the user closing the browser window in
wicket.

I followed this example:

http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value

and I managed to get the example working so the message is displayed, but I
have no idea how to get the event triggered by the javascript function in
wicket. I need this because when the user closes the browser window I want
to update some data in my database.
Here is what I have tryed:


 RequiredTextFieldString myTextField = new
RequiredTextFieldString(myTextField);
 myTextField.setOutputMarkupPlaceholderTag(true);
 myTextField.add(new PageExitWarningBehavior(){
@Override
public void onEvent(Component component, IEvent? event)
{
//this isn't ever called
MySession.get().releaseBlockedDataFromDatabase();
}
});

public class PageExitWarningBehavior extends Behavior  {
@Override
public void renderHead(Component component, IHeaderResponse
response) {
super.renderHead(component, response);
response.render(new
OnDomReadyHeaderItem(window.onbeforeunload = function (e) {
  + var message = 'Your confirmation message goes here.',
  + e = e || window.event; + if (e) {
  + e.returnValue = message; + } + return message; +
};));
}
}

What am I missing? Thank you very much in advance :-)


Re: Get return value of ajax event in Wicket 6.9.1

2013-11-11 Thread Martin Grigorov
Hi,

You need to make an Ajax call to the server.


On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com wrote:

 Hi,
 this is my first question, so i hope I get everything right.

 I am trying to catch the event of the user closing the browser window in
 wicket.

 I followed this example:


 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value

 and I managed to get the example working so the message is displayed, but I
 have no idea how to get the event triggered by the javascript function in
 wicket. I need this because when the user closes the browser window I want
 to update some data in my database.
 Here is what I have tryed:


  RequiredTextFieldString myTextField = new
 RequiredTextFieldString(myTextField);
  myTextField.setOutputMarkupPlaceholderTag(true);
  myTextField.add(new PageExitWarningBehavior(){
 @Override
 public void onEvent(Component component, IEvent? event)
 {
 //this isn't ever called
 MySession.get().releaseBlockedDataFromDatabase();
 }
 });

 public class PageExitWarningBehavior extends Behavior  {
 @Override
 public void renderHead(Component component, IHeaderResponse
 response) {
 super.renderHead(component, response);
 response.render(new
 OnDomReadyHeaderItem(window.onbeforeunload = function (e) {

  + Wicket.Ajax.get({u: '+getCallbackUrl()+', async:
false});

   + var message = 'Your confirmation message goes
 here.',

  + e = e || window.event; + if (e) {
   + e.returnValue = message; + } + return message; +
 };));
 }
 }

 What am I missing? Thank you very much in advance :-)



Re: Get return value of ajax event in Wicket 6.9.1

2013-11-11 Thread Daniela L
Hi,

as far as I have understood this can only be achieved, if I subclass
AbstractDefaultAjaxBehavior like this?

public class PageExitWarningBehavior extends AbstractDefaultAjaxBehavior  {
@Override
protected void respond(AjaxRequestTarget target) {
AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
  }


Hi,

You need to make an Ajax call to the server.


On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com
danigal...@gmail.com wrote:


Hi,
this is my first question, so i hope I get everything right.

I am trying to catch the event of the user closing the browser window in
wicket.

I followed this example:

http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value

and I managed to get the example working so the message is displayed, but I
have no idea how to get the event triggered by the javascript function in
wicket. I need this because when the user closes the browser window I want
to update some data in my database.
Here is what I have tryed:


 RequiredTextFieldString myTextField = new
RequiredTextFieldString(myTextField);
 myTextField.setOutputMarkupPlaceholderTag(true);
 myTextField.add(new PageExitWarningBehavior(){
@Override
public void onEvent(Component component, IEvent? event)
{
//this isn't ever called
MySession.get().releaseBlockedDataFromDatabase();
}
});

public class PageExitWarningBehavior extends Behavior  {
@Override
public void renderHead(Component component, IHeaderResponse
response) {
super.renderHead(component, response);
response.render(new
OnDomReadyHeaderItem(window.onbeforeunload = function (e) {


  + Wicket.Ajax.get({u: '+getCallbackUrl()+', async:
false});


  + var message = 'Your confirmation message goes
here.',

  + e = e || window.event; + if (e) {

  + e.returnValue = message; + } + return message; +
};));
}
}

What am I missing? Thank you very much in advance


Re: Get return value of ajax event in Wicket 6.9.1

2013-11-11 Thread Daniela L
Hi,

I have tryed to change to AbstractDefaultAjaxBehavior like I described
below, but respond is never called. What am I doing wrong?


Hi,

as far as I have understood this can only be achieved, if I subclass
AbstractDefaultAjaxBehavior like this?

public class PageExitWarningBehavior extends AbstractDefaultAjaxBehavior  {
@Override
protected void respond(AjaxRequestTarget target) {
AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
  }


Hi,

You need to make an Ajax call to the server.


On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com
danigal...@gmail.comdanigal...@gmail.com danigal...@gmail.com
wrote:


Hi,
this is my first question, so i hope I get everything right.

I am trying to catch the event of the user closing the browser window in
wicket.

I followed this example:
http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value

and I managed to get the example working so the message is displayed, but I
have no idea how to get the event triggered by the javascript function in
wicket. I need this because when the user closes the browser window I want
to update some data in my database.
Here is what I have tryed:


 RequiredTextFieldString myTextField = new
RequiredTextFieldString(myTextField);
 myTextField.setOutputMarkupPlaceholderTag(true);
 myTextField.add(new PageExitWarningBehavior(){
@Override
public void onEvent(Component component, IEvent? event)
{
//this isn't ever called
MySession.get().releaseBlockedDataFromDatabase();
}
});

public class PageExitWarningBehavior extends Behavior  {
@Override
public void renderHead(Component component, IHeaderResponse
response) {
super.renderHead(component, response);
response.render(new
OnDomReadyHeaderItem(window.onbeforeunload = function (e) {


  + Wicket.Ajax.get({u: '+getCallbackUrl()+', async:
false});


  + var message = 'Your confirmation message goes
here.',

  + e = e || window.event; + if (e) {

  + e.returnValue = message; + } + return message; +
};));
}
}

What am I missing? Thank you very much in advance


Re: Get return value of ajax event in Wicket 6.9.1

2013-11-11 Thread Martin Grigorov
Did you do what I suggested you ?


On Mon, Nov 11, 2013 at 3:49 PM, Daniela L danigal...@gmail.com wrote:

 Hi,

 I have tryed to change to AbstractDefaultAjaxBehavior like I described
 below, but respond is never called. What am I doing wrong?


 Hi,

 as far as I have understood this can only be achieved, if I subclass
 AbstractDefaultAjaxBehavior like this?

 public class PageExitWarningBehavior extends AbstractDefaultAjaxBehavior  {
 @Override
 protected void respond(AjaxRequestTarget target) {

 AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
   }


 Hi,

 You need to make an Ajax call to the server.


 On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com
 danigal...@gmail.comdanigal...@gmail.com danigal...@gmail.com
 wrote:


 Hi,
 this is my first question, so i hope I get everything right.

 I am trying to catch the event of the user closing the browser window in
 wicket.

 I followed this example:

 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value

 and I managed to get the example working so the message is displayed, but I
 have no idea how to get the event triggered by the javascript function in
 wicket. I need this because when the user closes the browser window I want
 to update some data in my database.
 Here is what I have tryed:


  RequiredTextFieldString myTextField = new
 RequiredTextFieldString(myTextField);
  myTextField.setOutputMarkupPlaceholderTag(true);
  myTextField.add(new PageExitWarningBehavior(){
 @Override
 public void onEvent(Component component, IEvent? event)
 {
 //this isn't ever called
 MySession.get().releaseBlockedDataFromDatabase();
 }
 });

 public class PageExitWarningBehavior extends Behavior  {
 @Override
 public void renderHead(Component component, IHeaderResponse
 response) {
 super.renderHead(component, response);
 response.render(new
 OnDomReadyHeaderItem(window.onbeforeunload = function (e) {


   + Wicket.Ajax.get({u: '+getCallbackUrl()+', async:
 false});


   + var message = 'Your confirmation message goes
 here.',

   + e = e || window.event; + if (e) {

   + e.returnValue = message; + } + return message; +
 };));
 }
 }

 What am I missing? Thank you very much in advance



Re: Get return value of ajax event in Wicket 6.9.1

2013-11-11 Thread Daniela L
I thought adding respond was the ajax call to the server, am I wrong?
I didn't work much with ajax, i am sorry


2013/11/11 Martin Grigorov mgrigo...@apache.org

 Did you do what I suggested you ?


 On Mon, Nov 11, 2013 at 3:49 PM, Daniela L danigal...@gmail.com wrote:

  Hi,
 
  I have tryed to change to AbstractDefaultAjaxBehavior like I described
  below, but respond is never called. What am I doing wrong?
 
 
  Hi,
 
  as far as I have understood this can only be achieved, if I subclass
  AbstractDefaultAjaxBehavior like this?
 
  public class PageExitWarningBehavior extends AbstractDefaultAjaxBehavior
  {
  @Override
  protected void respond(AjaxRequestTarget target) {
 
  AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
}
 
 
  Hi,
 
  You need to make an Ajax call to the server.
 
 
  On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com
  danigal...@gmail.comdanigal...@gmail.com danigal...@gmail.com
  wrote:
 
 
  Hi,
  this is my first question, so i hope I get everything right.
 
  I am trying to catch the event of the user closing the browser window in
  wicket.
 
  I followed this example:
 
 
 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value
 
  and I managed to get the example working so the message is displayed,
 but I
  have no idea how to get the event triggered by the javascript function in
  wicket. I need this because when the user closes the browser window I
 want
  to update some data in my database.
  Here is what I have tryed:
 
 
   RequiredTextFieldString myTextField = new
  RequiredTextFieldString(myTextField);
   myTextField.setOutputMarkupPlaceholderTag(true);
   myTextField.add(new PageExitWarningBehavior(){
  @Override
  public void onEvent(Component component, IEvent? event)
  {
  //this isn't ever called
  MySession.get().releaseBlockedDataFromDatabase();
  }
  });
 
  public class PageExitWarningBehavior extends Behavior  {
  @Override
  public void renderHead(Component component, IHeaderResponse
  response) {
  super.renderHead(component, response);
  response.render(new
  OnDomReadyHeaderItem(window.onbeforeunload = function (e) {
 
 
+ Wicket.Ajax.get({u: '+getCallbackUrl()+',
 async:
  false});
 
 
+ var message = 'Your confirmation message goes
  here.',
 
+ e = e || window.event; + if (e) {
 
+ e.returnValue = message; + } + return message;
 +
  };));
  }
  }
 
  What am I missing? Thank you very much in advance
 



Re: Get return value of ajax event in Wicket 6.9.1

2013-11-11 Thread Martin Grigorov
respond() is the callback method that Wicket will notify.
But you need to trigger an Ajax call first. This is done with the Wicket
Ajax API: Wicket.Ajax.get(...).

Just try with the line I've added in your JS code


On Mon, Nov 11, 2013 at 4:04 PM, Daniela L danigal...@gmail.com wrote:

 I thought adding respond was the ajax call to the server, am I wrong?
 I didn't work much with ajax, i am sorry


 2013/11/11 Martin Grigorov mgrigo...@apache.org

  Did you do what I suggested you ?
 
 
  On Mon, Nov 11, 2013 at 3:49 PM, Daniela L danigal...@gmail.com wrote:
 
   Hi,
  
   I have tryed to change to AbstractDefaultAjaxBehavior like I described
   below, but respond is never called. What am I doing wrong?
  
  
   Hi,
  
   as far as I have understood this can only be achieved, if I subclass
   AbstractDefaultAjaxBehavior like this?
  
   public class PageExitWarningBehavior extends
 AbstractDefaultAjaxBehavior
   {
   @Override
   protected void respond(AjaxRequestTarget target) {
  
   AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
 }
  
  
   Hi,
  
   You need to make an Ajax call to the server.
  
  
   On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com
   danigal...@gmail.comdanigal...@gmail.com danigal...@gmail.com
   wrote:
  
  
   Hi,
   this is my first question, so i hope I get everything right.
  
   I am trying to catch the event of the user closing the browser window
 in
   wicket.
  
   I followed this example:
  
  
 
 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value
  
   and I managed to get the example working so the message is displayed,
  but I
   have no idea how to get the event triggered by the javascript function
 in
   wicket. I need this because when the user closes the browser window I
  want
   to update some data in my database.
   Here is what I have tryed:
  
  
RequiredTextFieldString myTextField = new
   RequiredTextFieldString(myTextField);
myTextField.setOutputMarkupPlaceholderTag(true);
myTextField.add(new PageExitWarningBehavior(){
   @Override
   public void onEvent(Component component, IEvent? event)
   {
   //this isn't ever called
   MySession.get().releaseBlockedDataFromDatabase();
   }
   });
  
   public class PageExitWarningBehavior extends Behavior  {
   @Override
   public void renderHead(Component component, IHeaderResponse
   response) {
   super.renderHead(component, response);
   response.render(new
   OnDomReadyHeaderItem(window.onbeforeunload = function (e) {
  
  
 + Wicket.Ajax.get({u: '+getCallbackUrl()+',
  async:
   false});
  
  
 + var message = 'Your confirmation message goes
   here.',
  
 + e = e || window.event; + if (e) {
  
 + e.returnValue = message; + } + return
 message;
  +
   };));
   }
   }
  
   What am I missing? Thank you very much in advance
  
 



Re: Get return value of ajax event in Wicket 6.9.1

2013-11-11 Thread Cedric Gatay
AFAIK the browser won't issue a new server call (or will not process the
response) once the onunload event has been called so I doubt this will work
(using the web inspector of your browser will allow you to check whether or
not the call has been done)

I second what Martin said, you need to add the JavaScript code to call the
server.
Le 11 nov. 2013 15:29, Martin Grigorov mgrigo...@apache.org a écrit :

 respond() is the callback method that Wicket will notify.
 But you need to trigger an Ajax call first. This is done with the Wicket
 Ajax API: Wicket.Ajax.get(...).

 Just try with the line I've added in your JS code


 On Mon, Nov 11, 2013 at 4:04 PM, Daniela L danigal...@gmail.com wrote:

  I thought adding respond was the ajax call to the server, am I wrong?
  I didn't work much with ajax, i am sorry
 
 
  2013/11/11 Martin Grigorov mgrigo...@apache.org
 
   Did you do what I suggested you ?
  
  
   On Mon, Nov 11, 2013 at 3:49 PM, Daniela L danigal...@gmail.com
 wrote:
  
Hi,
   
I have tryed to change to AbstractDefaultAjaxBehavior like I
 described
below, but respond is never called. What am I doing wrong?
   
   
Hi,
   
as far as I have understood this can only be achieved, if I subclass
AbstractDefaultAjaxBehavior like this?
   
public class PageExitWarningBehavior extends
  AbstractDefaultAjaxBehavior
{
@Override
protected void respond(AjaxRequestTarget target) {
   
AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
  }
   
   
Hi,
   
You need to make an Ajax call to the server.
   
   
On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com
danigal...@gmail.comdanigal...@gmail.com danigal...@gmail.com
wrote:
   
   
Hi,
this is my first question, so i hope I get everything right.
   
I am trying to catch the event of the user closing the browser window
  in
wicket.
   
I followed this example:
   
   
  
 
 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value
   
and I managed to get the example working so the message is displayed,
   but I
have no idea how to get the event triggered by the javascript
 function
  in
wicket. I need this because when the user closes the browser window I
   want
to update some data in my database.
Here is what I have tryed:
   
   
 RequiredTextFieldString myTextField = new
RequiredTextFieldString(myTextField);
 myTextField.setOutputMarkupPlaceholderTag(true);
 myTextField.add(new PageExitWarningBehavior(){
@Override
public void onEvent(Component component, IEvent? event)
{
//this isn't ever called
MySession.get().releaseBlockedDataFromDatabase();
}
});
   
public class PageExitWarningBehavior extends Behavior  {
@Override
public void renderHead(Component component, IHeaderResponse
response) {
super.renderHead(component, response);
response.render(new
OnDomReadyHeaderItem(window.onbeforeunload = function (e) {
   
   
  + Wicket.Ajax.get({u: '+getCallbackUrl()+',
   async:
false});
   
   
  + var message = 'Your confirmation message goes
here.',
   
  + e = e || window.event; + if (e) {
   
  + e.returnValue = message; + } + return
  message;
   +
};));
}
}
   
What am I missing? Thank you very much in advance
   
  
 



Re: Get return value of ajax event in Wicket 6.9.1

2013-11-11 Thread Martin Grigorov
There is a difference between onunload and onbeforeunload. You can cancel
the latter.
You can make Ajax call only in onbeforeunload. And it has to be synchronous.


On Mon, Nov 11, 2013 at 4:55 PM, Cedric Gatay gata...@gmail.com wrote:

 AFAIK the browser won't issue a new server call (or will not process the
 response) once the onunload event has been called so I doubt this will work
 (using the web inspector of your browser will allow you to check whether or
 not the call has been done)

 I second what Martin said, you need to add the JavaScript code to call the
 server.
 Le 11 nov. 2013 15:29, Martin Grigorov mgrigo...@apache.org a écrit :

  respond() is the callback method that Wicket will notify.
  But you need to trigger an Ajax call first. This is done with the Wicket
  Ajax API: Wicket.Ajax.get(...).
 
  Just try with the line I've added in your JS code
 
 
  On Mon, Nov 11, 2013 at 4:04 PM, Daniela L danigal...@gmail.com wrote:
 
   I thought adding respond was the ajax call to the server, am I wrong?
   I didn't work much with ajax, i am sorry
  
  
   2013/11/11 Martin Grigorov mgrigo...@apache.org
  
Did you do what I suggested you ?
   
   
On Mon, Nov 11, 2013 at 3:49 PM, Daniela L danigal...@gmail.com
  wrote:
   
 Hi,

 I have tryed to change to AbstractDefaultAjaxBehavior like I
  described
 below, but respond is never called. What am I doing wrong?


 Hi,

 as far as I have understood this can only be achieved, if I
 subclass
 AbstractDefaultAjaxBehavior like this?

 public class PageExitWarningBehavior extends
   AbstractDefaultAjaxBehavior
 {
 @Override
 protected void respond(AjaxRequestTarget target) {

 AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
   }


 Hi,

 You need to make an Ajax call to the server.


 On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com
 danigal...@gmail.comdanigal...@gmail.com danigal...@gmail.com
 
 wrote:


 Hi,
 this is my first question, so i hope I get everything right.

 I am trying to catch the event of the user closing the browser
 window
   in
 wicket.

 I followed this example:


   
  
 
 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value

 and I managed to get the example working so the message is
 displayed,
but I
 have no idea how to get the event triggered by the javascript
  function
   in
 wicket. I need this because when the user closes the browser
 window I
want
 to update some data in my database.
 Here is what I have tryed:


  RequiredTextFieldString myTextField = new
 RequiredTextFieldString(myTextField);
  myTextField.setOutputMarkupPlaceholderTag(true);
  myTextField.add(new PageExitWarningBehavior(){
 @Override
 public void onEvent(Component component, IEvent?
 event)
 {
 //this isn't ever called
 MySession.get().releaseBlockedDataFromDatabase();
 }
 });

 public class PageExitWarningBehavior extends Behavior  {
 @Override
 public void renderHead(Component component, IHeaderResponse
 response) {
 super.renderHead(component, response);
 response.render(new
 OnDomReadyHeaderItem(window.onbeforeunload = function (e) {


   + Wicket.Ajax.get({u:
 '+getCallbackUrl()+',
async:
 false});


   + var message = 'Your confirmation message goes
 here.',

   + e = e || window.event; + if (e) {

   + e.returnValue = message; + } + return
   message;
+
 };));
 }
 }

 What am I missing? Thank you very much in advance

   
  
 



Re: Get return value of ajax event in Wicket 6.9.1

2013-11-11 Thread Cedric Gatay
I was on my phone and didn't read that well the provided snippet, it should
work fine then ;)

__
Cedric Gatay (@Cedric_Gatay http://twitter.com/Cedric_Gatay)
http://code-troopers.com | http://www.bloggure.info | http://cedric.gatay.fr


On Mon, Nov 11, 2013 at 4:05 PM, Martin Grigorov mgrigo...@apache.orgwrote:

 There is a difference between onunload and onbeforeunload. You can cancel
 the latter.
 You can make Ajax call only in onbeforeunload. And it has to be
 synchronous.


 On Mon, Nov 11, 2013 at 4:55 PM, Cedric Gatay gata...@gmail.com wrote:

  AFAIK the browser won't issue a new server call (or will not process the
  response) once the onunload event has been called so I doubt this will
 work
  (using the web inspector of your browser will allow you to check whether
 or
  not the call has been done)
 
  I second what Martin said, you need to add the JavaScript code to call
 the
  server.
  Le 11 nov. 2013 15:29, Martin Grigorov mgrigo...@apache.org a écrit
 :
 
   respond() is the callback method that Wicket will notify.
   But you need to trigger an Ajax call first. This is done with the
 Wicket
   Ajax API: Wicket.Ajax.get(...).
  
   Just try with the line I've added in your JS code
  
  
   On Mon, Nov 11, 2013 at 4:04 PM, Daniela L danigal...@gmail.com
 wrote:
  
I thought adding respond was the ajax call to the server, am I wrong?
I didn't work much with ajax, i am sorry
   
   
2013/11/11 Martin Grigorov mgrigo...@apache.org
   
 Did you do what I suggested you ?


 On Mon, Nov 11, 2013 at 3:49 PM, Daniela L danigal...@gmail.com
   wrote:

  Hi,
 
  I have tryed to change to AbstractDefaultAjaxBehavior like I
   described
  below, but respond is never called. What am I doing wrong?
 
 
  Hi,
 
  as far as I have understood this can only be achieved, if I
  subclass
  AbstractDefaultAjaxBehavior like this?
 
  public class PageExitWarningBehavior extends
AbstractDefaultAjaxBehavior
  {
  @Override
  protected void respond(AjaxRequestTarget target) {
 
  AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
}
 
 
  Hi,
 
  You need to make an Ajax call to the server.
 
 
  On Mon, Nov 11, 2013 at 2:10 PM, Daniela L danigal...@gmail.com
 
  danigal...@gmail.comdanigal...@gmail.com 
 danigal...@gmail.com
  
  wrote:
 
 
  Hi,
  this is my first question, so i hope I get everything right.
 
  I am trying to catch the event of the user closing the browser
  window
in
  wicket.
 
  I followed this example:
 
 

   
  
 
 http://stackoverflow.com/questions/16527463/call-java-component-from-javascript-and-retreive-value
 
  and I managed to get the example working so the message is
  displayed,
 but I
  have no idea how to get the event triggered by the javascript
   function
in
  wicket. I need this because when the user closes the browser
  window I
 want
  to update some data in my database.
  Here is what I have tryed:
 
 
   RequiredTextFieldString myTextField = new
  RequiredTextFieldString(myTextField);
   myTextField.setOutputMarkupPlaceholderTag(true);
   myTextField.add(new PageExitWarningBehavior(){
  @Override
  public void onEvent(Component component, IEvent?
  event)
  {
  //this isn't ever called
  MySession.get().releaseBlockedDataFromDatabase();
  }
  });
 
  public class PageExitWarningBehavior extends Behavior  {
  @Override
  public void renderHead(Component component,
 IHeaderResponse
  response) {
  super.renderHead(component, response);
  response.render(new
  OnDomReadyHeaderItem(window.onbeforeunload = function (e) {
 
 
+ Wicket.Ajax.get({u:
  '+getCallbackUrl()+',
 async:
  false});
 
 
+ var message = 'Your confirmation message
 goes
  here.',
 
+ e = e || window.event; + if (e) {
 
+ e.returnValue = message; + } + return
message;
 +
  };));
  }
  }
 
  What am I missing? Thank you very much in advance