I think the problem is that when you use the onClick event of a submit button that code is executed by the browser before the submit of the form. I think that's the reason why it is not working.

This is a possible solution (I did not test it)

1. Create a String on your java class

public String myAction = "no";

2. Relate the String to the value binding of a WOHiddenField that you place inside your form and set a name:

tfMyAction : WOHiddenField {
  value = myAction;
  name = "myActionField";
}

3. Set a name for your form

Form1: WOForm {
.....
  name = "myForm";
...
}

4. Use a JavaScript Function like this:

function saveAndClose() {
        document.myForm.myActionField.value = "savedPage";
        document.myForm.submit();
///// Close the window but after 1 second to allow the browser submit the form
        setTimeout("window.close()",1000);
}


5. in Your java class

 public void takeValuesFromRequest(WORequest r, WOContext c){
  super.takeValuesFromRequest(r, c);
  if(accion.equals("savedPage")){
   savedPage();
  }
 }

6 In your savedPage  funtion set the myAction variable to "no".


7. Use a simple hiperlink (I am not sure that it could work with a submit button)

<a href="#" onClick = "saveAndClose();"> Close Window </a>


I think it could work.

Good look!




______________________________
Ing. Miguel Angel Torres Avila




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to