You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Thomas Bednarz <th...@bednarz.ch> on 2002/03/01 17:57:52 UTC

ActionForward question

Hi,

Is it possible to send pages to a browser depending on the processing status
of an action? Lets say you have to process a long operation in the
background such as a credit card validation or the like, is it possible to
show the user an intermediate page telling him that some work is in progress
and then show the result page when it is generated?

In the Action class it looks like this:

        // test if session is valid
        af = super.validateForm(form, mapping, request);
        if (af != null) return af;
        // test if a form has already been delivered
        if ((ContainerName == null) || (ContainerName.length() < 1))  //show
form
        {
            saveToken(request);
            return (new
ActionForward("/Templates/Forms/ShowEnumNTGGForm.vm"));
        }

        if (this.isTokenValid(request))
        {
            resetToken(request);
            //
****************************************************************************
***********************
            //   START PROCESSING HERE THIS COULD LAST 30 SECONDS OR
MORE....
            //   IF I ADD SOMETHING LIKE A new ActionForward("some status
message URL"); THE
           //    FOLLOWING CODE WILL EXECUTE BUT THE FORWARD AT THE BOTTOM
WILL NEVER
           //     REACH THE BROWSER !
           //
****************************************************************************
***************************
            try
            {
                container = getNTContainer("Domain", ContainerName,
request);
                request.setAttribute("NTContainer", container);
            } catch (SmartSolException e)
            {
                errors.add(ActionErrors.GLOBAL_ERROR,
                           new ActionError("error.exception.smartsol", new
Integer(e.ErrorCode).toString(), e.File ,e.ErrorMsg));
            }
        } else
        {
            errors.add(ActionErrors.GLOBAL_ERROR, new
ActionError("error.BePatient"));
        }
        // Report any errors we have discovered back to the original form
        af = super.processErrors(errors, mapping, request);
        if (af != null)
        {
            log.debug("finished perform with errors.");
            return (af);
        }
        // Forward control to the specified success URI
        log.debug("finished perform with success");
        return (new ActionForward("/Templates/NTAccounts/EnumNTGG.vm"));
-------   end quote --------------------------

How can this problem be solved?

Many thanks!

Thomas


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: ActionForward question

Posted by Robert Nocera <rn...@neosllc.com>.
Your best bet is to set up an intermediate page that uses Javascript to
do automatic refreshes. 

There were a couple other suggestions on this list a little while ago.
One was to set up a page that lists the transactions in progress and
their status and have the user refresh the page themselves.

You can't use http to push stuff out to a browser, only respond to
requests, and once you respond, you're stuck waiting for the user to
make another request.

Robert Nocera
New England Open Solutions
www.neosllc.com
"You supply the vision, we'll do the rest."
 

-----Original Message-----
From: Thomas Bednarz [mailto:thomas@bednarz.ch] 
Sent: Friday, March 01, 2002 11:58 AM
To: struts user list
Subject: ActionForward question

Hi,

Is it possible to send pages to a browser depending on the processing
status
of an action? Lets say you have to process a long operation in the
background such as a credit card validation or the like, is it possible
to
show the user an intermediate page telling him that some work is in
progress
and then show the result page when it is generated?

In the Action class it looks like this:

        // test if session is valid
        af = super.validateForm(form, mapping, request);
        if (af != null) return af;
        // test if a form has already been delivered
        if ((ContainerName == null) || (ContainerName.length() < 1))
//show
form
        {
            saveToken(request);
            return (new
ActionForward("/Templates/Forms/ShowEnumNTGGForm.vm"));
        }

        if (this.isTokenValid(request))
        {
            resetToken(request);
            //
************************************************************************
****
***********************
            //   START PROCESSING HERE THIS COULD LAST 30 SECONDS OR
MORE....
            //   IF I ADD SOMETHING LIKE A new ActionForward("some
status
message URL"); THE
           //    FOLLOWING CODE WILL EXECUTE BUT THE FORWARD AT THE
BOTTOM
WILL NEVER
           //     REACH THE BROWSER !
           //
************************************************************************
****
***************************
            try
            {
                container = getNTContainer("Domain", ContainerName,
request);
                request.setAttribute("NTContainer", container);
            } catch (SmartSolException e)
            {
                errors.add(ActionErrors.GLOBAL_ERROR,
                           new ActionError("error.exception.smartsol",
new
Integer(e.ErrorCode).toString(), e.File ,e.ErrorMsg));
            }
        } else
        {
            errors.add(ActionErrors.GLOBAL_ERROR, new
ActionError("error.BePatient"));
        }
        // Report any errors we have discovered back to the original
form
        af = super.processErrors(errors, mapping, request);
        if (af != null)
        {
            log.debug("finished perform with errors.");
            return (af);
        }
        // Forward control to the specified success URI
        log.debug("finished perform with success");
        return (new ActionForward("/Templates/NTAccounts/EnumNTGG.vm"));
-------   end quote --------------------------

How can this problem be solved?

Many thanks!

Thomas


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>