After clicking on continue on the loginWarning.jsp page, I no longer have
the username and password fields that are validated in the validate method
of the loginForm.  How should I make this available?  Thanks.

-----Original Message-----
From: Craig Tataryn [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 06, 2002 11:01 PM
To: [EMAIL PROTECTED]
Subject: Re: Two Phase ActionClass


Sean, not sure if I would recycle the login page to show the warning, 
instead I would have another page called loginWarning.jsp which showed them 
a message and then presented a Continue and Cancel button.  The Continue 
button would send them back to the logon Action class and the Cancel button 
would simply be a link back to the login.jsp page.

However, I would change my Action class to a DispatchAction class and setup 
things like they have in the DispatchAction API doc, in your case, something

like this:

<action path="/loginUser"
   type="my.package.LoginUserAction"
   name="subscriptionForm"
   scope="request"
   input="/login.jsp"
   parameter="action">

   <forward name="warn" path="/loginWarning.jsp"/>
   <forward success path="afterLogin.jsp"/>
</action>

I would then have two jsps, one for logging in (login.jsp) and then the one 
for warning (loginWarning.jsp), and I would code my DispatachAction class as

follows:

import org.apache.struts.action.DispatchAction;

public class LoginUserAction extends DispatchAction {
//have one method named for each possible function name you will be
//passing in the "action" parameter

//invoked when our Action class is called with action=showWarningIfNecessary
public ActionForward showWarningIfNecessary(ActionMapping mapping, 
ActionForm form, HttpServletRequest request, HttpServletResponse response) 
throws Exception
{
   //if the user is already logged in
   //return mappings.findForward("warning");
   //else return mappings.findForward("success");
}

//invoked when our Action class is called with action=continue
public ActionForward continue(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response) throws Exception
{
   return mappings.findForward("success");
}

}

In login.jsp, you would have a hidden form field with a name of "action" and

a value of "showWarningIfNecessary":

<html:hidden name="action" value="showWarningIfNecessary"/>

In loginWarning.jsp your continue button could just be a link to:
loginUser.do?action=continue (or you could have a hidden field named action 
like in login.jsp, but the value would be "continue")

And your cancel button could be a link to:
login.jsp

If you read the API doc on DispatchAction, this will all make sense.

Hope that helped!

Craig.

>From: "Cohan, Sean" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
>Subject: Two Phase ActionClass
>Date: Fri, 6 Sep 2002 20:14:37 -0400
>
>Within my logon ActionClass, I want to check the user's user id/password 
>and
>whether they are currently logged on anywhere else.  If they are logged on
>elsewhere, I want to go back to the logon page to warn them and give them a
>chance to continue or to bail.  If they continue, I want to skip over the
>check whether they are logged on elsewhere.  I'm struggling with how from 
>my
>logon.jsp page I can instruct the logon action to one thing one time and
>another thing another time.  I was thinking maybe the ActionMapping
>parameter, but I don't really know how to use it.  I'm searching.  Can
>someone give me a good way to do what I'm trying to do?  Should I go to a
>different ActionClass instead of trying to use the same one?
>
>Also, I was going to return the warning to the user in ActionErrors.  Is
>there a way I can poll the error from the jsp (logic tag?) and then if it's
>this warning put a yes/no form on the logon page?  Or should I warn them on
>a different page?  I do want other ActionErrors to display without the
>yes/no form (e.g., username required.)  Thanks.
>
>--
>To unsubscribe, e-mail:   
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: 
><mailto:[EMAIL PROTECTED]>
>


Craig W. Tataryn
Programmer/Analyst
Compuware

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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

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

Reply via email to