aspose file tools*
The moose likes Struts and the fly likes Refresh parent window without closing popup with struts validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Refresh parent window without closing popup with struts validation" Watch "Refresh parent window without closing popup with struts validation" New topic
Author

Refresh parent window without closing popup with struts validation

Rajagopal Mani
Ranch Hand

Joined: Mar 24, 2011
Posts: 84

Hi,

I am using struts 1.2.

Main page is having 'Add' button which can open add popup window. In popup window there are so many fields which are validated by struts validator framework by click 'Update' button. Once validation success, the corresponding popup window action(UpdateAction.java) has to be executed and parent window should be refreshed without closing popup window.

The above is the requirement. How can i achieve? please help.
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi Mani,
There is nothing to do with struts for this. Do the action call as usual. Submit your pop up request and on body load use


Have Fun with Java
little,little.. little by little makes a lot..
Rajagopal Mani
Ranch Hand

Joined: Mar 24, 2011
Posts: 84

Hi,

Thanks for the reply. If action call as usual, the forward jsp also should be mapped as well. Assume the forwarded jsp is like below,

Dummy.jsp


struts-config.xml


If popup is not closed explicitly, the forwarded jsp(empty page) is displayed in popup screen. However, the parent screen is reloaded. If popup is closed, this problem is ignored. But as per the requirement, the popup screen should keep display. Is there any way to have only action class to be executed without any forwarded jsp mapping in struts MVC architecture? please suggest if there is any better solution and point out if am doing any mistake.
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

well, my understanding of your problem is as below.
You have say, parent.jsp, popup.jsp
Upon accessing "Add" button in your parent.jsp it opens popup.jsp (action 1)
Now on performing some selection in popup.jsp you submit the form (action 2) to add it in the parent jsp.

To solve your problem,
After performing "action 2" in your action class forward control back to "action 1" using struts (what it does is, it would refresh your popup, you would not get the blank screen). While doing so, just put up some param to identify that this is coming after performing "action 2".
Now when the popup reloads check for this param and refresh the parent window as mentioned earlier. Thats it!

In the above code you are forwarding it to dummy (which is not the actual popup.jsp) jsp which is not necessary and leading you to blank screen.

Additionally, If you do not want your pop up to be refreshed, just use asyn call (AJAX) to do it for you.

Rajagopal Mani
Ranch Hand

Joined: Mar 24, 2011
Posts: 84

Hi,


After performing "action 2" in your action class forward control back to "action 1" using struts


The above scenario could be acheived without forwarding to "action 1" with input attribute and without forward tag as like below.



In action 2,


But as mentioned, the popup jsp will be refreshed. I believed like there may be better solution(without refresh popup) in this case regard. However i will try to use AJAX as you mentioned. But i would like to confirm that usage of AJAX tech to struts application will overload/overhead the application? Please clarify if am not correct.
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Well, in general AJAX is not the only option though, but for your scenario wherein usage of server push technology is not permitted (I suppose) using simple Struts 1.x application and to suffice your business requirement we have to compromise on something (as always). But I don't see any such major problem in your case. What would be the maximum (rough) user base for your web application concurrently?
I would say it is not at all a problem since, you would not be transporting much data across to cause any overhead, it would be just a param, right?
Rajagopal Mani
Ranch Hand

Joined: Mar 24, 2011
Posts: 84

Thanks for your reply & suggestion. I will investigate further and try to modify the design.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Refresh parent window without closing popup with struts validation