You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Galbreath <be...@dirtroad.net> on 2002/01/17 21:06:48 UTC

Action Passing a Class Instance?

I'm new (2 days) to Struts and cannot find any good documentation nor
tutorials to satisfactorily explain the API in a practical sense.

Anyway, I need to pass control from one class to another in a web app
something like:

public String getNextPage() throws Exception {
    Command nextCommand = new ListEquipmentAction();
    nextCommand.setAttributes( this);
    nextCommand.execute();

    return nextCommand.getNextPage();
}

How do I go about doing this in the form:

return( mapping.findForward( "success"));

?

Thanks,
Mark


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


Re: Action Passing a Class Instance?

Posted by Mark Galbreath <be...@dirtroad.net>.
Thanks alot, Mark!

Mark

----- Original Message -----
From: "Mark Woon" <mo...@SMI.Stanford.EDU>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, January 17, 2002 8:31 PM
Subject: Re: Action Passing a Class Instance?


> Mark Galbreath wrote:
>
> > Thanks so very much!  I have found very little on how the Struts API can
> > actually be used in practice, and even less on struts-config.xml.  I
> > actually assumed that that is how it must be done.  That being said, I
still
> > don't have a clue as to the actual implementation.  It sure would be
nice if
> > the Jakarta folks would put together something along the lines of the
> > excellent tutorials available at java.sun.com!
>
> The struts-config.xml DTD can be found at
> http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd (as mentioned
in the
> DTD declaration, second item in struts-config.xml).  It took me a while to
> figure this one out myself...  ;)
>
> If you downloaded the tarball, definitely take a look at the example
webapp
> (struts-example.war).  It was a huge help in getting me started.  That and
this
> mailing list...
>
> Also take a look at http://www.husted.com/struts/, by the same guy (Ted
> Husted) who put the example above together.  There should definitely be
enough
> to keep you occupied.
>
> Most of the information available is not so much of the tutorial variety,
but
> more of the example-you-can-build-from variety.
>
> -Mark
>
>
>
> --
> 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>


Re: Action Passing a Class Instance?

Posted by Mark Woon <mo...@SMI.Stanford.EDU>.
Mark Galbreath wrote:

> Thanks so very much!  I have found very little on how the Struts API can
> actually be used in practice, and even less on struts-config.xml.  I
> actually assumed that that is how it must be done.  That being said, I still
> don't have a clue as to the actual implementation.  It sure would be nice if
> the Jakarta folks would put together something along the lines of the
> excellent tutorials available at java.sun.com!

The struts-config.xml DTD can be found at
http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd (as mentioned in the
DTD declaration, second item in struts-config.xml).  It took me a while to
figure this one out myself...  ;)

If you downloaded the tarball, definitely take a look at the example webapp
(struts-example.war).  It was a huge help in getting me started.  That and this
mailing list...

Also take a look at http://www.husted.com/struts/, by the same guy (Ted
Husted) who put the example above together.  There should definitely be enough
to keep you occupied.

Most of the information available is not so much of the tutorial variety, but
more of the example-you-can-build-from variety.

-Mark



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


Re: Action Passing a Class Instance?

Posted by Mark Galbreath <be...@dirtroad.net>.
Thanks so very much!  I have found very little on how the Struts API can
actually be used in practice, and even less on struts-config.xml.  I
actually assumed that that is how it must be done.  That being said, I still
don't have a clue as to the actual implementation.  It sure would be nice if
the Jakarta folks would put together something along the lines of the
excellent tutorials available at java.sun.com!

Cheers!
Mark

----- Original Message -----
From: "Mark Woon" <mo...@SMI.Stanford.EDU>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, January 17, 2002 6:21 PM
Subject: Re: Action Passing a Class Instance?


> Mark Galbreath wrote:
>
> > Anyway, I need to pass control from one class to another in a web app
> > something like:
> >
> > public String getNextPage() throws Exception {
> >     Command nextCommand = new ListEquipmentAction();
> >     nextCommand.setAttributes( this);
> >     nextCommand.execute();
> >
> >     return nextCommand.getNextPage();
> >
> >
> > How do I go about doing this in the form:
> >
> > return( mapping.findForward( "success"));
>
> In your Action:
>
> public ActionForward perform(...) {
>
>     request.setAttribute(key, this);
>     return (mapping.findForward("success"));
> }
>
>
> The mapping "success" is defined in /WEB-INF/struts-config.xml.  The
mapping can
> point to another class (Action) that will do somethinng different.
>
>
> So basically when someone requests a page, your Action gets control, it
does
> some processing, sets whatever attributes it needs to set, and then
forwards
> control on to something else.  What that something else is defined in
> /WEB-INF/struts-config.xml.
>
> Hope that helps.  I'm sure the Struts gurus will chime in to clarify... ;)
>
> -Another Mark
>
>
> --
> 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>


Re: Action Passing a Class Instance?

Posted by Mark Woon <mo...@SMI.Stanford.EDU>.
Mark Galbreath wrote:

> Anyway, I need to pass control from one class to another in a web app
> something like:
>
> public String getNextPage() throws Exception {
>     Command nextCommand = new ListEquipmentAction();
>     nextCommand.setAttributes( this);
>     nextCommand.execute();
>
>     return nextCommand.getNextPage();
>
>
> How do I go about doing this in the form:
>
> return( mapping.findForward( "success"));

In your Action:

public ActionForward perform(...) {

    request.setAttribute(key, this);
    return (mapping.findForward("success"));
}


The mapping "success" is defined in /WEB-INF/struts-config.xml.  The mapping can
point to another class (Action) that will do somethinng different.


So basically when someone requests a page, your Action gets control, it does
some processing, sets whatever attributes it needs to set, and then forwards
control on to something else.  What that something else is defined in
/WEB-INF/struts-config.xml.

Hope that helps.  I'm sure the Struts gurus will chime in to clarify... ;)

-Another Mark


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