You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Johnson <ch...@gmail.com> on 2005/07/11 19:49:47 UTC

Changing Form Target in Action?

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

-- 
-Dave
ChaChaNY@Gmail.com

Re: Changing Form Target in Action?

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
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 <ch...@gmail.com> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
> 

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


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Changing Form Target in Action?

Posted by Michael Jouravlev <jm...@gmail.com>.
On 7/11/05, David Johnson <ch...@gmail.com> 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Changing Form Target in Action?

Posted by Michael Jouravlev <jm...@gmail.com>.
On 7/11/05, Joe Germuska <Jo...@germuska.com> wrote:
> When I've had to do something like this in the past, I didn't
> actually change the target, but rather caused the response page to
> use the new target as part of its page loading.  That is, the
> response page would have an onload handler which would load the
> necessary content in a new target.

This looks easier than to call validate() from already opened popup. I
like this one.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Changing Form Target in Action?

Posted by Rick Reumann <st...@reumann.net>.
David Johnson wrote the following on 7/11/2005 2:23 PM:
> Joe
>  Oh this one sounds good. I'm not sure how I'd actually DO that though.. can 
> you provide more info? All my pages are tiles definitions right now. How 
> would I cause the response page to use the new target (conditionally)?

what about something like... one JSP page for form.

<html>
<html:form action="yourAction>
    //form inputs plus the hidden.. first submit is just validating
    <input type="hidden" name="dispatch" value="validateMe">
</html:form>

//bottom of JSP .. although probably will work fine up top
<c:if test="${openPDF}">
   <script>
	document.forms[0].target=newTarget;
  	document.forms[0].dispatch.value="pdfProcess";
         document.forms[0].submit();
   </script>
</c:if>
</html>

Your dispatch Action:

validateMe(...) {
   form.validate()...
   //if ok ...
   request.setAttribute("openPDF",true);
   //else if failed...save errors
   request.setAttribute("openPDF",false);
   //forward to same JSP
}

pdfProcess(..) {
   //normal proces of form data to create your PDF or whatever
   //forward page to display PDF
}


Key is to call validate manually in your action.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: PASSWORD DIGESTION...RealmBase import problem...help please!

Posted by Martin Gainty <mg...@hotmail.com>.
Oke

Did you read the "How to configure realm" how to doc and follow the 
instructions ?
Take a look at
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/realm-howto.html

Also
Its been my experience 8.3 folder are identified coorectly where as NTFS 
file names sometimes identified correctly
e.g.
D:\apps\Apache\Tomcat\tomcat-5.5.9\common\lib\servlet-api.jar become
D:\apps\Apache\Tomcat\TOMCAT~1\common\lib\servlet-api.jar

Good Luck,
Martin

----- Original Message ----- 
From: "O. Oke" <re...@yahoo.co.uk>
To: <us...@struts.apache.org>
Sent: Monday, July 11, 2005 3:42 PM
Subject: PASSWORD DIGESTION...RealmBase import problem...help please!


> Help please!
>
> BACKGROUND
> ==========
> I want to store the digested version of user's
> password in the database.  Therefore, I imported
> org.apache.catalina.realm.RealmBase so that I can use
> the static DIGEST method in the class for the
> digestion of the password
> i.e.Digest(myBean.getUser_pass()).
>
> I am using Eclipse 3.0.2, tomcat-5.5.9 and JDK 1.5
>
> PROBLEM
> =======
> After importing org.apache.catalina.realm.RealmBase
> class, I keep getting error msg: "The import
> org.apache.catalina cannot be resolved".  I do not
> expect to get this error because I have followed the
> instructions on how to achieve my objective correctly.
> The instructions are here:
> http://jakarta.apache.org/tomcat/tomcat-5.5-doc/realm-howto.html#Digested%20Passwords
>
> In line with the instructions, I added catalina.jar to
> my classpath; please see classpath below:
>
> CLASSPATH=.;D:\apps\Apache\Tomcat\tomcat-5.5.9\common\lib\servlet-api.jar;D:\apps\Apache\Tomcat\tomcat-5.5.9\common\lib\jsp-api.jar;D:\apps\Apache\Tomcat\tomcat-5.5.9\server\lib\catalina.jar
>
> In DOS the RealmBase class was found, it is only in
> the action class that it is not found - cannot be
> resolved.
>
> Everything to do with password/login is working,
> except for digestion.  As I have pointed out it has
> not been possible to enable digestion because of the
> problem with importing the class.
>
> Can anyone please tell me what I need to do to get
> round the import problem?  I hasten to point out, I
> even restarted my machine after adding catalina.jar to
> my classpath.
>
>
>
> Thank you.
>
> Ola'dele Oke
>
>
>
>
>
> ___________________________________________________________
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with 
> voicemail http://uk.messenger.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


PASSWORD DIGESTION...RealmBase import problem...help please!

Posted by "O. Oke" <re...@yahoo.co.uk>.
Help please!

BACKGROUND
==========
I want to store the digested version of user's
password in the database.  Therefore, I imported
org.apache.catalina.realm.RealmBase so that I can use
the static DIGEST method in the class for the
digestion of the password
i.e.Digest(myBean.getUser_pass()).

I am using Eclipse 3.0.2, tomcat-5.5.9 and JDK 1.5

PROBLEM
=======
After importing org.apache.catalina.realm.RealmBase
class, I keep getting error msg: "The import
org.apache.catalina cannot be resolved".  I do not
expect to get this error because I have followed the
instructions on how to achieve my objective correctly.
 The instructions are here:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/realm-howto.html#Digested%20Passwords

In line with the instructions, I added catalina.jar to
my classpath; please see classpath below:

CLASSPATH=.;D:\apps\Apache\Tomcat\tomcat-5.5.9\common\lib\servlet-api.jar;D:\apps\Apache\Tomcat\tomcat-5.5.9\common\lib\jsp-api.jar;D:\apps\Apache\Tomcat\tomcat-5.5.9\server\lib\catalina.jar

In DOS the RealmBase class was found, it is only in
the action class that it is not found - cannot be
resolved.

Everything to do with password/login is working,
except for digestion.  As I have pointed out it has
not been possible to enable digestion because of the
problem with importing the class.

Can anyone please tell me what I need to do to get
round the import problem?  I hasten to point out, I
even restarted my machine after adding catalina.jar to
my classpath.



Thank you.

Ola'dele Oke


	
	
		
___________________________________________________________ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


PASSWORD DIGESTION...RealmBase import problem...help please!

Posted by "O. Oke" <re...@yahoo.co.uk>.
Help please!

BACKGROUND
==========
I want to store the digested version of user's
password in the database.  Therefore, I imported
org.apache.catalina.realm.RealmBase so that I can use
the static DIGEST method in the class for the
digestion of the password
i.e.Digest(myBean.getUser_pass()).

I am using Eclipse 3.0.2, tomcat-5.5.9 and JDK 1.5

PROBLEM
=======
After importing org.apache.catalina.realm.RealmBase
class, I keep getting error msg: "The import
org.apache.catalina cannot be resolved".  I do not
expect to get this error because I have followed the
instructions on how to achieve my objective correctly.
 The instructions are here:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/realm-howto.html#Digested%20Passwords

In line with the instructions, I added catalina.jar to
my classpath; please see classpath below:

CLASSPATH=.;D:\apps\Apache\Tomcat\tomcat-5.5.9\common\lib\servlet-api.jar;D:\apps\Apache\Tomcat\tomcat-5.5.9\common\lib\jsp-api.jar;D:\apps\Apache\Tomcat\tomcat-5.5.9\server\lib\catalina.jar

In DOS the RealmBase class was found, it is only in
the action class that it is not found - cannot be
resolved.

Everything to do with password/login is working,
except for digestion.  As I have pointed out it has
not been possible to enable digestion because of the
problem with importing the class.

Can anyone please tell me what I need to do to get
round the import problem?  I hasten to point out, I
even restarted my machine after adding catalina.jar to
my classpath.



Thank you.

Ola'dele Oke


		
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Changing Form Target in Action?

Posted by David Johnson <ch...@gmail.com>.
Joe
 Oh this one sounds good. I'm not sure how I'd actually DO that though.. can 
you provide more info? All my pages are tiles definitions right now. How 
would I cause the response page to use the new target (conditionally)?

 On 7/11/05, Joe Germuska <Jo...@germuska.com> wrote: 
> 
> When I've had to do something like this in the past, I didn't
> actually change the target, but rather caused the response page to
> use the new target as part of its page loading. That is, the
> response page would have an onload handler which would load the
> necessary content in a new target.
> 
> If your new target is a new window, pop-up blockers may foil this,
> and of course, you'll have to make sure to preserve any relevant
> state, since the onload handler will initiate a separate request.
> 
> Can you make that work?
> 
> Joe
> 
> 
> At 1:49 PM -0400 7/11/05, David Johnson 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
> >
> >--
> >-Dave
> >ChaChaNY@Gmail.com
> 
> 
> --
> Joe Germuska
> Joe@Germuska.com
> http://blog.germuska.com
> "Narrow minds are weapons made for mass destruction" -The Ex
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
-Dave
ChaChaNY@Gmail.com

Re: Changing Form Target in Action?

Posted by David Johnson <ch...@gmail.com>.
Hmm.
 I suppose it would be easier to just do the validation in JavaScript... but 
I **really** dont want to. It just seems inconsistent.
 So there's no way to change what browser the validate() returns to once 
I've submitted the form and I'm in the validate() method? Some attribute on 
the request perhaps? I mean the request has to know where it's forwarding 
to, right?
 On 7/11/05, Joe Germuska <Jo...@germuska.com> wrote: 
> 
> When I've had to do something like this in the past, I didn't
> actually change the target, but rather caused the response page to
> use the new target as part of its page loading. That is, the
> response page would have an onload handler which would load the
> necessary content in a new target.
> 
> If your new target is a new window, pop-up blockers may foil this,
> and of course, you'll have to make sure to preserve any relevant
> state, since the onload handler will initiate a separate request.
> 
> Can you make that work?
> 
> Joe
> 
> 
> At 1:49 PM -0400 7/11/05, David Johnson 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
> >
> >--
> >-Dave
> >ChaChaNY@Gmail.com
> 
> 
> --
> Joe Germuska
> Joe@Germuska.com
> http://blog.germuska.com
> "Narrow minds are weapons made for mass destruction" -The Ex
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
-Dave
ChaChaNY@Gmail.com

Re: Changing Form Target in Action?

Posted by Joe Germuska <Jo...@Germuska.com>.
When I've had to do something like this in the past, I didn't 
actually change the target, but rather caused the response page to 
use the new target as part of its page loading.  That is, the 
response page would have an onload handler which would load the 
necessary content in a new target.

If your new target is a new window, pop-up blockers may foil this, 
and of course, you'll have to make sure to preserve any relevant 
state, since the onload handler will initiate a separate request.

Can you make that work?

Joe


At 1:49 PM -0400 7/11/05, David Johnson 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
>
>--
>-Dave
>ChaChaNY@Gmail.com


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Changing Form Target in Action?

Posted by Rick Reumann <st...@reumann.net>.
David Johnson wrote the following on 7/11/2005 1:49 PM:
> 
> 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...

Hmmm, not sure about this, this sounds tricky but I bet someone more 
knowledgeable knows the answer.

I think most of the work will have to have to be on the client side. In 
other words, at a first stab at this, on the resulting page you'll need 
a test for the errors present and if so, then force a reload of the 
other window you came from and close this new window that you spawned. 
In order to make sure the errors you want show up on the original page 
when it refreshes you'll have to probably store the errors initially in 
the Session so that the other page will see them or pass the error 
message(s) in the url/action that you call from the new window which is 
used to refresh the old. Haven't done this myself, so I could be wrong 
or there may be an easier way.

-- 
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org