popup, db retrieval and original page refreshing in struts

Here's the scenario.
I have an struts app that works like this.

I type in a url:  http://localhost/actions/OrderDetail.do?orderNo=1234
The action corresponding to this .do does the retrieval  of db info for that order and saves in an OrderBean.
Struts then forwards me to OrderDetail.jsp.  This OrderDetail.jsp outputs the info pertaining to that order.
That's what's done.  Here's what I need.

In that jsp, I need to have a link called "ChangeOrderDetail" which takes me to a popup which allows me to change a couple of fields for that order.
When I submit that popup page, (let's call it ChangeOrderDetail.jsp) , I want the popup page to close and to be taken to ChangeOrderDetailAction, which would save the new data in db.  I then want the original OrderDetail.jsp to be automatically refreshed (by invoking the url http://localhost/actions/OrderDetail.do?orderNo=1234 again) so it can get repopulated with the new data from the db.

How do I do that?  Please provide the relevant code sample.

Thank you so much.
LVL 1
aturetskyAsked:
Who is Participating?
 
bloodredsunCommented:
Fine.

Here you go. Here's an example of everything I've been saying that does everything you ask...

popup_parent.jsp
------------------------------------
<%@ page language="java" contentType="text/html" %>
<html>
</head>
<title>
Parent
</title>
<script type="text/javascript">
function popme(){
      window.open("popup_child.jsp?page=1234","Pop UP","scrollbars=yes,resizable=yes,location=no,width=150,height=150");
}
</script>
</head>
<body>
page param?:<%=request.getParameter("page")%><br>
Click <a href="javascript:popme()">here</a> for popup


</body>
</html>


popup_child.jsp
-----------------------------
<%@ page language="java" contentType="text/html" %>
<html>
</head>
<title>Child</title>
<script type="text/javascript">
function popback(){
      window.opener.document.location.href = "popup_parent.jsp?page=bertandernie" ;//change parent
      self.location.href = "popup_child.jsp?page=bananas" ; //change self e.g. submit request
}
</script>
</head>
<body>
Thanks <%=request.getParameter("page")%>,
Click <a href="javascript:popback()">here</a> to kick everything off
</body>
</html>
-----------

I'm a little annoyed as you have apparently opened a new question that asks the same answer while ignoring the solution I suggested, which I feel is a little inconsiderate, if not rude. You say that I didn't give you a "precise response" even though I gave you the code that would solve your problem with a little application on your behalf.

The main reason that I'm giving you this code is that I feel other users may benefit from knowing how to submit the parent page from the popup.

aturetsky, you've asked questions before so you know that we experts don't get paid for this but do it for the fun. I understand that you may be under a time deadline but please be a little more thoughtful in the future.

regards,

brs
0
 
bloodredsunCommented:
I have something similar to this but it's at work. I will be able to forward you some code mid-morning GMT.

What my code did was for an address populating pop-up. You type the postcode/zip code in the form and click go and and it populated the form of the window that had created the pop-up. If this sounds useful to you, I'll be happy to supply you with a version of it.
0
 
aturetskyAuthor Commented:
it sounds like what I want except I really need it today
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
bloodredsunCommented:
As far as popups go, this is an useful script for populating the values in the parent page from the pop-up page. You can modify this to do things ilke change the location of the parent page.
-----------
    <script type="text/javascript">

      function pasteAddress(){


      window.opener.document.forms[0].elements["<%=pFormName%>Address1"].value = document.PopupForm.Address[0].value + " ";
      window.opener.document.forms[0].elements["<%=pFormName%>Address2"].value = document.PopupForm.Address[1].value + " " + document.PopupForm.Address[2].value + " "  ;
      window.opener.document.forms[0].elements["<%=pFormName%>TownOrCity"].value = document.PopupForm.Address[3].value  + " ";
      window.opener.document.forms[0].elements["<%=pFormName%>County"].value = document.PopupForm.Address[4].value + " ";
      window.opener.document.forms[0].elements["<%=pFormName%>Postcode"].value = document.PopupForm.Address[5].value + " ";


      self.close();
      }

    </script>
-----------------

If you used the session rather than storing everything in the database immediately then your pop-up could just access this.
0
 
aturetskyAuthor Commented:
I haven't finished it yet - so I would have use for the script you mentioned you have at work yesterday.

Note, however, that, as I described above, when submitted, my popup needs to invoke an action to store data in db, reload the url of the originating  page, and then close itself.
0
 
aturetskyAuthor Commented:
Still looking.
0
 
bloodredsunCommented:
>>my popup needs to invoke an action to store data in db

then use:
window.opener.document.location.href = "my new value"

to resubmit the action before the pop up closes
0
 
aturetskyAuthor Commented:
I am confused, it's the popup itself that needs to be sumitted to an action.

Can you post a complete solution.  Because of lack of precise response,  I have the question reformulated better at http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21406022.html.
0
 
bloodredsunCommented:
>> Because of lack of precise response

Lack of response from whom?!?
0
 
aturetskyAuthor Commented:
Bloodredsun, you've been very helpful to me on many  questions with your expertise and to say anything that's unfair to  you would be the least of my intentions.

I did not say "lack of response," I said "lack of precise response."  What I  am  saying is that I have not received a precise answer to the question that  I  am asking,  which  I think is true.
What you posted thus far was a "useful script for populating the values in the parent page from the pop-up page" and suggestion to use window.opener.document.location.href = "my new value".   I therefore was not sure if I had formulated the question well enough so I  decided to  start from scratch.

Please be assured that I was in no way motivated by any negative considerations in your regard, being that I don't have any.

Having said that, if  you feel I  am wrong, please accept my apology.
0
 
aturetskyAuthor Commented:
>>I'm a little annoyed as you have apparently opened a new question that asks the same answer while ignoring the solution I suggested, which I feel is a little inconsiderate, if not rude. >>You say that I didn't give you a "precise response" even though I gave you the code that would solve your problem with a little application on your behalf.

I am sorry I made you feel this way.  But... Which code are you referring to?  This one?   "this is an useful script for populating the values in the parent page from the pop-up page. You can modify this to do things ilke change the location of the parent page"  But I do not understand why I need to change the location of the parent page, so I did not think this code is applicable to me.

>>  users may benefit from knowing how to submit the parent page from the popup
Unless I am missing something, that 's not what I am looking to do.  In my case the  popup is submitted to its own action that does the db saving.  I don't need to resubmit the parent page.  I just need to reload the url that took me to that parent page in the first place.  And that needs to happen after the popup is subitted to its own action.

So I still think you're missing my question which  is why I reformulated it.

>> aturetsky, you've asked questions before so you know that we experts don't get paid for this but do it for the fun. I understand that you may be under a time deadline but please be a little more thoughtful in the future.

That's true.  I know you're not getting paid and I  am very thankful for all your past and current help.  Although sometimes I may sound like I take it for granted, I never do.






0
 
aturetskyAuthor Commented:
any response?
0
 
aturetskyAuthor Commented:
brs, I've already gotten a solution to my question from a third party a few days ago, but out of respect for the time, effort and expertise that you've shared with me, I would feel wrong not giving you points - so if you have a response to my questions to your proposed solution, please send it over.  I mean if what you've written above does constitute a solution and I just don't realize, just say so, and explain why, please, so I can give points.

BTW, here's the solution that I've gotten and implemented:

The target page of B.do will have the javascript which will first
reload A.do and close the window.

B.do should forward to this page once it inserts the data in the DB.

Example closeWindow.jsp
CODE

<%@ page contentType="text/html;charset=windows-1252"%>
<html>
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
   <title>Close Window</title>
 </head>
 <body>
  <script language="javascript"><!--
     opener.location.href = opener.location.href;
     window.close();
  //-->
  </script>
 </body>
</html>
0
 
bloodredsunCommented:
Hi Alex,

firstly thanks for the email. It was very polite and frankly made me feel a bit stupid for having a bit of a pop at you. I'm sorry that I can't always give questioners at EE as much time as they deserve as I do have a full-time job that is quite demanding and as it looked like I couldn't help you I had unsubscribed which meant that I was no longer receiving updates to this thread.

It's great news that you've found a solution and that you have posted it so that others can also see it. As it's from a third party, you would be well within your rights to ask for a full refund of your points.

Looking at the solution made me smile as it's so obvious. I think that we were communicating at cross points, especially with regard to this post from me, right at the top:

>>window.opener.document.location.href = "my new value"
>>to resubmit the action before the pop up closes

"window.opener.document.location.href" is the full version of the shorter "opener.location.href" that is used in your script, and of course, there's only one way to close a window in javascript. I didn't realise that you wanted to submit the opener page to itself but rather to another page, which is why I never specified a value.

So thanks Alex, and good luck with your project.
0
 
aturetskyAuthor Commented:
Message to Potential Reader of this Question:

Please note that the answer to this particular question is different from the very userful answer to a somewhat different question that I marked as the accepted answer.

For the answer to this particular question, see comment from myself, aturetsky, above (Date: 05/03/2005 10:39AM CDT).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.