aspose file tools*
The moose likes Struts and the fly likes struts and javascript pop up window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts and javascript pop up window" Watch "struts and javascript pop up window" New topic
Author

struts and javascript pop up window

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 375
In my JSP page, there is a hyperlink like "/app/myAction.do?value=2", What I want to do is --

When clicking this link, first do some business logic calculation, if the result is positive, then pop up a javascript window showing the messge, but keep the current JSP page UNchanged; if the result is negative, then forward to a new page.

How to do this ? I don't think the struts-config.xml allows you to forward to javascript pop up .... So, can I incorporate the logic into the Action class ? don't know how to do this...
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
There are a couple of ways you might do this:

1- Define two forwards for myAction: one to return to the page just displayed (jsp1), and the other to go to the new page (jsp2). Also, add a boolean property to your ActionForm to indicate whether to do the popup or not (doPopup) If the response is positive, set doPopup to true and forward to jsp1. Otherwise, forward to jsp2.

In jsp1, code something like the following:


This will cause the popup window to appear if the flag is set.

2 - Use AJAX to call the business logic on the server. Based on the response you receive, either open a popup window or submit the form.

I'm currently using the DWR Framework to handle AJAX calls, and I'm very happy with it.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts and javascript pop up window