Hi David,

If I'm understanding your goal correctly, then you won't be able to do this without some sort of scripting because the form target is a purely client-side attribute, you won't be able to change it from the server-side, which is really what you'd want to do.

If scripting is OK with you, there are some approaches...

(1) Use Ajax... submit the form and render the response. When you get it back, examine it... if it's an error response (you'll have to figure out how to determine this based on what your app does), then your still on the page and can do whatever you like (i.e., show errors, whatever). If it's not an error response, open a popup at that point, or perhaps just display what was sent back in a <div>, what is appropriate.

(2) Along the lines of 1, use frames... target your form to a hidden frame (set rows or cols, depending on the layour, to 0). When the response comes back, include in it some simple Javascript that either opens the popup and copies the HTML over to it, or display error responses, in response to onLoad.

(3) As Michael suggested, target the new window as your doing now, and simply return some Javascript that either closes the popup, and probably pass the error information back to the parent before that, or continue as usual. This happens in response to the onLoad event of course.

#1 is probably the approach that gives the best UI experience, but #3 is probably the simplest to implement. All require scripting though. If you decide to go with #1, the AjaxTags component of my Java Web Parts project may save you a lot of time (http://javawebparts.sourceforge.net). If you go with either of the other suggestions, feel free to ping me if you have specific questions about them.

Frank

Michael Jouravlev wrote:
On 7/11/05, David Johnson <[EMAIL PROTECTED]> wrote:

Hi all
I have the following problem:
I have a button on my form that uses javascript to change to form target
before submitting because I'm exporting an RTF generated in my action to the
new browser, as follows

<html:submit property="exportFlag"
onclick="set('export');setFormTarget('_export')"
disabled="false">Create Graph (Popup)</html:submit>

function setFormTarget(newTarget){
document.forms[0].target=newTarget;
}

The thing is I want to be able to use the validate() method in my Form
object and return to the ORIGINAL browser if an error is encountered...

so is there anything I can do within the action to affect that?

Thanks


I never done stuff with popup windows, but I would consider trying
something like this:

* you open a new window and submit to action which validates input
(automatic validation is turned off);
* you manually call validate() from action class, and if input is
incorrect, you return a small html with javascript, which would close
current window (which is a popup), and would redirect to main window.
The downside: would not work without javascript. The location of main
window should be set either in struts-config.xml or maybe passed as
parameter or maybe found out via referer... Also, to show errors after
redirect you would have to stick them into session beforehand. Or to
append to redirected request.
* if data is ok, you respond with pdf to popup window directly or
forward/redirect
to action which responds with pdf.

As a side note, I personally don't like apps which open windows
themselves. I prefer to use "Open in a new window" option if I need it
in a new window.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to