• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

form submitting on html link

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using frames in my application. The left frame has the navigation hyperlinks and the right frame as the form fields like text boxes.

Now I am trying to implement refresh functionality, so that after entering data on page1.jsp and if I click the Page1 hyperlink, the page1.jsp should be submitted and the data on it should be read and stored into the sessison.

I am having problem with form submit. I am doing like this:

<html:link action="/Page1.do?actionType=refresh" onKlick="javascript: document.myForm.submit()" target="dataEntryPage"> Personal</html:link> 

and I have a ActionForward method refresh() in the Page1Action.java class which reads the data from the form

Line of code from Page1Action.java

Page1Bean pa = new Page1Bean();
pa.Name = (String) form.get("Name");
System.out.println("Name: " + pa.Name);

When I do that, its just printing Name:
And no data what ever I entered on the form text field.

Structs Config Action Mapping for this is:

<action path="/Page1Link" name="Page1Form" type="org.tiaa.tda.action.PersonalInfoAction"
parameter="actionType" scope="request" >

<forward name="refresh" path="/jsp/Personal.jsp" redirect="true" />

</action>

I hope the form is not submitting.
Can anyone suggest me how should I submit a form in this case.

Thanks in Advance,
Naveen
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Naveen:

It seems that you meet the same problemm I met couple days ago, please check that thread (a html:link problem):

https://coderanch.com/t/51791/Struts/html-link

hope it may help.

Thanks
David
 
Naveen bpl
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

Actually I went through your post before I added a new post. I tried the way it was suggested in your post, but it didn't work for me. So I made new post.

Thanks,
Naveen
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me see if I understand the problem corrently. You have a link in a navaigation bar frame that will cause page 1 to display in the dataEntryPage frame. But if you're currently already displaying page 1 in the dataEntryPage frame and the user clicks the page 1 link, you want it to submit page 1 before redisplaying it, right?

First off, you need a way of telling whether Page 1 is currently displayed in the dataEntryPage frame or not. I'd suggest setting a global javascript variable (for example g_page) containing the identity of the page currently displayed in the dataEntryPage frame. So, for each page you display, set g_page to "pageone" or "pagetwo" or whatever the page is.

When the user clicks the link in the navigaion bar, test if parent.dataEntryPage.g_page is "pageone". If not, have the link do what it currently does. If so, have the link submit the form in the dataEntryPage frame, NOT the form in the navigation bar frame. So, the command would be: parent.dataEntryPage.forms[0].submit();
 
Naveen bpl
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Merrill,

Thanks a lot for your help, I did the way you have suggested me. Its working except that its opening the popups. I have a navigation panel jsp on the left side of the page. So when I submit the page, its opening a new empty page besides and the original page still has both the navigation panel and also the pag1 jsp. And the address of that empy page shows the navigation panel jsp addres.

I am doing a submit as shown below using the javascript.

<html:link action="/Page1.do?actionType=refresh" onKlick="doRefresh()" target="dataEntryPage"> Page1</html:link>

<script language="JavaScript">

function doRefresh()
{
document.forms[0].action = '/tdaomni/Page1.do' ;
document.forms[0].submit() ;
}

</script>

Please suggest me what's the reason for the navigation panel to be opened in a differnt page, though the newly opened page is empty and the actual page still has the navigation panel.

Thanks,
Naveen
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are encountering this problem because your script is submitting the form for the wrong frame. It should submit the form for the dataEntryPage frame, not the navigationBar frame. In Javascript, you refer to another frame by first referring to "parent", which is a reference to the frameSet that caused the current frame to be displayed. From there, you can get a reference to another frame by name.

Therefore, your doRefresh script should read:

parent.dataEntryPage.document.forms[0].submit()


This will submit whatever form is in dataEntryPage frame, so you will want to check to make sure the right page is in the frame before submitting the form.
 
Naveen bpl
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,

Thanks for suggesting me. I tried the way by adding the parent.dataentrypage.document.forms[0].submit();

but I still have the same problem of the new empty IE page opening as I explained before.

Thanks,
Naveen
 
reply
    Bookmark Topic Watch Topic
  • New Topic