469,270 Members | 1,780 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

submit a form after confirmation through a customised window

Hi all,
I want to submit a form after confirmation through a customised window. I have 4 buttons in <af:form>, one of which is continue button that has to navigate the form to another page while executing the action:
--------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. <af:commandButton id="continueBtn"
  2.     onclick="return NewWindow()"
  3.     action="#{CoverageMPB.process}" text="continue" />
----------------------------------------------------------------
javascript:
-------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. function NewWindow(){
  2. window.open("url","fg","height=250,width=700");
  3. return false;
  4. }
  5.  
  6. function check(){
  7. if(document.forms[0].radios[0].checked){
  8. self.close();
  9. document.parent.getElementById("my_form").submit(); 
  10.                   //my_form is the id of <af:form> that is the parent document's form.
  11. }
  12. else {
  13. self.close();
  14. }
  15. }
-------------------------------------------------------------------------
child window: (jsf file)
----------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. <af:form  id="form1" >
  2.         <af:panelBorder id="boder1">
  3.              <af:panelForm labelWidth="5%" id="form2">
  4.                      <af:panelHorizontal>
  5.                      <af:selectOneRadio id="radios" layout="horizontal"  value="" onclick="check()">
  6.                       <af:selectItem label="Yes"   value="Yes"></af:selectItem>
  7.                        <af:objectSpacer width="5"/>
  8.                       <af:selectItem label="No"  value="No"></af:selectItem>
  9.                      </af:selectOneRadio>
  10.                    </af:panelHorizontal>
  11.              </af:panelForm>    
  12.         </af:panelBorder>
  13. </af:form>
------------------------------------------------------------------------------------------
Can anybody help me in finding out why the form is not getting submitted when i click on Yes?
Oct 17 '07 #1
9 5310
gits
5,390 Expert Mod 4TB
hi ...

change this:

Expand|Select|Wrap|Line Numbers
  1. document.parent.getElementById("my_form").submit();
  2.  
to:

Expand|Select|Wrap|Line Numbers
  1. opener.document.getElementById("my_form").submit();
kind regards
Oct 17 '07 #2
Hi,
Thanks for replying. But I've tried putting even that statement. But its not working.
Oct 17 '07 #3
gits
5,390 Expert Mod 4TB
try an alert before that statement ... may be you should close the window after! trying to submit?

kind regards
Oct 17 '07 #4
gits
5,390 Expert Mod 4TB
and try to trace whether your condition returns true!

kind regards
Oct 17 '07 #5
yeah i have done that also. it does return true and it can even click another button in parent form when i replaced submit statement with getElementById("button2id").click();.
I mean condition is being satisfied for sure and it is able to access the parent form's elements. But doesn't submit the form



and try to trace whether your condition returns true!

kind regards
Oct 17 '07 #6
gits
5,390 Expert Mod 4TB
i'm confused now ... is it a popup window or a frame? please try to explain the related application-design very clear ... in case you have a frame ... then you have a parent ... in case you have a popupwindow or another window at all ... it should be the opener. please explain it in more detail ...

kind regards
Oct 17 '07 #7
ok. see, I have page1.jsf that has submit button. when i click on this button a pop up window should be opened that has a group of 2 radio buttons: "Yes" and "No". Upon selecting any radio button, pop up should be closed. further, if "yes" was selected, page should be submitted.



i'm confused now ... is it a popup window or a frame? please try to explain the related application-design very clear ... in case you have a frame ... then you have a parent ... in case you have a popupwindow or another window at all ... it should be the opener. please explain it in more detail ...

kind regards
Oct 17 '07 #8
gits
5,390 Expert Mod 4TB
hi ...

in this case the following function should work:

Expand|Select|Wrap|Line Numbers
  1. function check() {
  2.     if (document.forms[0].radios[0].checked) {
  3.         opener.document.getElementById('my_form').submit();
  4.     } 
  5.  
  6.     window.close();
  7. }
try it and let me know whether you get any errors with that or not?

kind regards
Oct 17 '07 #9
HI, it was also not working. Then, I changed the logic. Instead of submitting, I am now, clicking that button again and based on a variable (hidden field), making it return true. Now, it's working fine. Anyways, thanks for responses.

hi ...

in this case the following function should work:

Expand|Select|Wrap|Line Numbers
  1. function check() {
  2.     if (document.forms[0].radios[0].checked) {
  3.         opener.document.getElementById('my_form').submit();
  4.     } 
  5.  
  6.     window.close();
  7. }
try it and let me know whether you get any errors with that or not?

kind regards
Oct 18 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Terence Parker | last post: by
13 posts views Thread by John Kiernan | last post: by
oll3i
3 posts views Thread by oll3i | last post: by
11 posts views Thread by V S Rawat | last post: by
4 posts views Thread by John Straumann | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.