FarscapePROJ
FarscapePROJ

Reputation: 285

Open new window from GSP and forward to external URL

I need some help. I am converting a Struts application to Grails.

There is a particular action I am trying to convert.

  1. There is a form in a jsp that asks a user to select a customer from a dropdown list and the user clicks one of two buttons.
  2. When the user clicks on the "View Reports" button, an onclick event calls a javascript function that issues window.open on a STRUTS action class, passing the selected customer and selected action.
  3. In the action class the http request has some attributes set (request.setAttribute (..)) and a forward is performed to an external application. The attributes that where set are used by the application for sign on. This is done as a POST.

My problem is I am not quite sure how to wire this flow using the Grails framework. I was able to get as far as the user selecting a customer, clicking an actionSubmit button, reading the selected customer from params, adding my attributes to 'request' and then..I am stuck.

How to open a new window? (Tried javascript way as was done with Struts).

Also I am able to issue a redirect to the external site in the controller, however a redirect is done as a GET and not a POST, as well as the redirect is done in the same window. Any help in laying this out would be awesome. Thanks

Upvotes: 0

Views: 2278

Answers (2)

L_7337
L_7337

Reputation: 2748

In Grails, I've used createLink, with the 'base' attribute to do this.

<g:createLink base="${params.dynamicURL}">Link</g:createLink>

I think something like this would work, but you can research it here: http://grails.org/doc/latest/ref/Tags/createLink.html

Upvotes: 1

leomeurer
leomeurer

Reputation: 752

You can't redirect a user from server using POST.

I can see some possible solutions:

1 . If you don't need to pass through your server to validate or request some data, you can use this:

<form action="http://someotherserver.com" method="post">

2 . Create a controller that redirect to a page in your own site and in this page make a treatment that receives the paramters and then redirect the user to another domain using ajax.

Upvotes: 2

Related Questions