• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts and javascript pop up window

 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic