You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yen <hy...@leadingside.com> on 2005/04/22 04:39:25 UTC

Action call another action?

Hi,

I have an action which save the data into the database, after the saving, I 
would like to forward to the listing page, where I have another action doing 
the listing.

Should I repeat the same listing method (method list) in the save action 
itself..? Or, is there any better way?

Thanks for advanced.

rgds,
Yen

public ActionForward save(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response)
{
    method save..
    method list..
   return (mapping.findForward("afflist"));
}

public ActionForward listing(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response)
{
    method list
   return (mapping.findForward("afflist"));
} 


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


Re: Action call another action?

Posted by Erik Weber <er...@mindspring.com>.
Let me just make sure I'm being clear, since you appear to use separate 
Actions whereas I typically use one.

I do it like this:

execute( . . .) {
  //switch
  case view:
    getDelegate().doViewStuff();
    break;
  case save:
    getDelegate().doSaveStuff();
    getDelegate().doViewStuff();
    break;
  . . .
}

Even though you have a different design, I think we're talking about the 
same thing. Please disregard if we're not.

Erik



Erik Weber wrote:

> That's the way I do it. If your Actions are light, as they should be, 
> it doesn't add a lot of code. Some redundant code is not a bad thing, 
> it can make things clearer. If you were to "chain" actions, then you'd 
> be going through the entire request processor chain again.
>
> I think that Struts 1.3, with chain of responsibility implementation, 
> should allow chaining of actions without causing redundant processing, 
> but I can't say for sure (at least I hope it does).
>
> Erik
>
>
> Yen wrote:
>
>> Hi,
>>
>> I have an action which save the data into the database, after the 
>> saving, I would like to forward to the listing page, where I have 
>> another action doing the listing.
>>
>> Should I repeat the same listing method (method list) in the save 
>> action itself..? Or, is there any better way?
>>
>> Thanks for advanced.
>>
>> rgds,
>> Yen
>>
>> public ActionForward save(ActionMapping mapping, ActionForm form, 
>> HttpServletRequest request, HttpServletResponse response)
>> {
>>    method save..
>>    method list..
>>   return (mapping.findForward("afflist"));
>> }
>>
>> public ActionForward listing(ActionMapping mapping, ActionForm form, 
>> HttpServletRequest request, HttpServletResponse response)
>> {
>>    method list
>>   return (mapping.findForward("afflist"));
>> }
>>
>> ---------------------------------------------------------------------
>> 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
>
>

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


Re: Action call another action?

Posted by Michael Jouravlev <jm...@gmail.com>.
> I have an action which save the data into the database, after the saving, I
> would like to forward to the listing page, where I have another action doing
> the listing.
> 
> Should I repeat the same listing method (method list) in the save action
> itself..? Or, is there any better way?

...

> whenever I did an add action, then go back to the listing page, whenever 
> I click the Next/Previous, it will add another record, and keep adding.

No. You have an action which shows item. It submits data to Save
Action. Save Action stores data in the database and redirects (not
forwards!) to the list. If you use redirect, you can reload your list
or do anything else.

The action which shows the list, must use session-scoped form bean (or
other session-scoped data), and store there the page number, if you
want to return to particular page. I am not sure what do you have to
do if you add or delete item, since you might need to repaginate.

Also read this: http://wiki.apache.org/struts/StrutsMultipleActionForms
You might like two action / two form approach. See example of Edit
Action and Save Action. Check out samle application here:
http://www.superinterface.com/rdapp/viewList.do Try to play with
Refrest/Back/Forward buttons. Try to resubmit the newly created item.

Michael.

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


Re: Action call another action?

Posted by Yen <hy...@leadingside.com>.
The problem is, I use ValueList for the listing page, it will automaticaaly append the action=add when selecting the next/previous page.

so, after I add the record, it will go to the listing page (return (mapping.findForward("afflist"))), at the same time, it will append the action=add (base on the previous action)..

That means, whenever I did an add action, then go back to the listing page, whenever I click the Next/Previous, it will add another record, and keep adding.

I tried to do like this..
<forward name="myafflist" path="/Affiliations.action?execute=showlist" />   
 <forward name="afflist" path="/ad.affiliations.affiliations.screen" />   
 <forward name="addaff" path="/ad.affiliations.details.screen" />

In the add action, I forward to "myafflist" rather than the usual "afflist".. the listing page still append the action=add after I did the add action

http://localhost:7001/myweb/Affiliations.action?aff_name=h&remarks=h&pagingPage=2&year_joined=h&execute=list&execute=add&

it sounds funny, but at least... it works now..

anyone any better idea?


----- Original Message ----- 
From: "Erik Weber" <er...@mindspring.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Friday, April 22, 2005 10:48 AM
Subject: Re: Action call another action?


> That's the way I do it. If your Actions are light, as they should be, it 
> doesn't add a lot of code. Some redundant code is not a bad thing, it 
> can make things clearer. If you were to "chain" actions, then you'd be 
> going through the entire request processor chain again.
> 
> I think that Struts 1.3, with chain of responsibility implementation, 
> should allow chaining of actions without causing redundant processing, 
> but I can't say for sure (at least I hope it does).
> 
> Erik
> 
> 
> Yen wrote:
> 
>> Hi,
>>
>> I have an action which save the data into the database, after the 
>> saving, I would like to forward to the listing page, where I have 
>> another action doing the listing.
>>
>> Should I repeat the same listing method (method list) in the save 
>> action itself..? Or, is there any better way?
>>
>> Thanks for advanced.
>>
>> rgds,
>> Yen
>>
>> public ActionForward save(ActionMapping mapping, ActionForm form, 
>> HttpServletRequest request, HttpServletResponse response)
>> {
>>    method save..
>>    method list..
>>   return (mapping.findForward("afflist"));
>> }
>>
>> public ActionForward listing(ActionMapping mapping, ActionForm form, 
>> HttpServletRequest request, HttpServletResponse response)
>> {
>>    method list
>>   return (mapping.findForward("afflist"));
>> }
>>
>> ---------------------------------------------------------------------
>> 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
> 
>

Re: Action call another action?

Posted by Dakota Jack <da...@gmail.com>.
You can deduce all you want, Joe, but this is mistaken.  I notice that
according to your logic, I am now Joe.

Joe

On 4/24/05, Joe Germuska <Jo...@germuska.com> wrote:
> At 3:08 PM -0700 4/24/05, Shey Rab Pawo wrote:
> ><SNIP>
> >On 4/24/05, James Mitchell <jm...@apache.org> wrote:
> >>  For the record, you are encouraged to ignore all statements made by Micael
> >>  McGrady, Dakota Jack, or Shey Rab Pawo.
> >  These people are actually the same
> >>  person masquerading as alternate identities,
> ></SNIP>
> >
> >You are quite mistaken about this, James.
> 
> Are you saying that James is mistaken in claiming that these three
> identities are used by one person?
> 
> I thought this message from Shey's account by signed by "Jack" was
> kind of strange.
> 
> http://marc.theaimsgroup.com/?l=struts-user&m=110961169006532&w=2
> 
> More clearly, this message to the Server Side is from "Michael
> McGrady", but is signed "Dakota Jack":
> http://theserverside.com/news/thread.tss?thread_id=31509#154946
> 
> I have been puzzling about this, particularly when a few days ago
> messages came from both Jack and Shey within 20 minutes of each other.
> 
> Joe
> 
> --
> 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
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Re: Action call another action?

Posted by Joe Germuska <Jo...@Germuska.com>.
At 3:08 PM -0700 4/24/05, Shey Rab Pawo wrote:
><SNIP>
>On 4/24/05, James Mitchell <jm...@apache.org> wrote:
>>  For the record, you are encouraged to ignore all statements made by Micael
>>  McGrady, Dakota Jack, or Shey Rab Pawo.
>  These people are actually the same
>>  person masquerading as alternate identities,
></SNIP>
>
>You are quite mistaken about this, James.

Are you saying that James is mistaken in claiming that these three 
identities are used by one person?

I thought this message from Shey's account by signed by "Jack" was 
kind of strange.

http://marc.theaimsgroup.com/?l=struts-user&m=110961169006532&w=2

More clearly, this message to the Server Side is from "Michael 
McGrady", but is signed "Dakota Jack":
http://theserverside.com/news/thread.tss?thread_id=31509#154946

I have been puzzling about this, particularly when a few days ago 
messages came from both Jack and Shey within 20 minutes of each other.

Joe

-- 
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: Action call another action?

Posted by Shey Rab Pawo <pa...@gmail.com>.
<SNIP>
On 4/24/05, James Mitchell <jm...@apache.org> wrote:
> For the record, you are encouraged to ignore all statements made by Micael
> McGrady, Dakota Jack, or Shey Rab Pawo. 
 These people are actually the same
> person masquerading as alternate identities, 
</SNIP>

You are quite mistaken about this, James.  I am not sure what upset
you about my statements about CoR.  I also have no idea why you think
what I said was "outmoded" or at all offensive.




<SNIP> 
> I may be mistaken but I think that the CoR (Chain of Responsibility)
> pattern in Struts 1.3 is not going to be for "actions" per se
> (although anyone can always use the CoR pattern) but for creating an
> extensible RequestProcessor.  I may, as I said, be mistaken about
> that, but the general buzz has given me that impression.
> 
> Shey Rab Pawo
</SNIP>



-- 
No one ever went blind looking at the bright side of life.

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


Re: How can I get people to look at my contribution? [was: Re: Action ...

Posted by Dakota Jack <da...@gmail.com>.
James has been and will continue to be, no doubt, a great asset to
Struts.  What that has to do with his misconception discussed in this
thread is beyond me.  But, as an aside, James, you have my "atta boy"
too.

Jack

On 4/25/05, Ted Husted <te...@gmail.com> wrote:
> The plain truth is that an ASF project is not a democracy. It a
> meritocracy. People earn merit and credibility by doing things that
> matter and avoiding things that don't matter.
> 
> One way to earn merit and credibility is to make helpful posts. But
> hurtful, unhelpful posts destroy merit just as easily. One step
> forward, three steps back.
> 
> Like all open source projects, Struts doesn't need critics, we need
> models. What we need most is people like James, who create extensions,
> and contribute to the codebase, and volunteer the time and energy it
> takes to keep this project running, day after day.
> 
> James Mtichell is a Committer and a member of the Struts PMC. Over the
> years, through his many contributions, he's earned a lot of merit with
> this community. Most recently, James did the work of fixing our
> nightly builds. If he did not do that work, then we might not have
> nightly builds right now. James didn't do it because someone paid him
> to do it. James did it because he wanted to make a difference (in a
> good way).
> 
> When James speaks, I listen. Why? because James has earned a lot of
> merit and credibility in my eyes.
> 
> Anyone with an email account can post to this list. But, not everyone
> takes the time and energy to do the work of this project, the way
> James does, and Martin does, and Don does, and Joe does, and Niall
> does, and Hubert does.
> 
> Not because anyone pays them to do it (no one does), but because they
> simply want to make the Struts project a better place. Not by
> criticizing, but by making it so.
> 
> -Ted.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Re: How can I get people to look at my contribution? [was: Re: Action ...

Posted by Dave Newton <ne...@pingsite.com>.
Ted Husted wrote:

>Anyone with an email account can post to this list. 
>
That'll teach 'em to give me an email account.

Muahahahahaha!

All your Struts are belong to us.

Dave "I thought something weird was going on" Newton



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


Re: How can I get people to look at my contribution? [was: Re: Action ...

Posted by Ted Husted <te...@gmail.com>.
The plain truth is that an ASF project is not a democracy. It a
meritocracy. People earn merit and credibility by doing things that
matter and avoiding things that don't matter.

One way to earn merit and credibility is to make helpful posts. But
hurtful, unhelpful posts destroy merit just as easily. One step
forward, three steps back.

Like all open source projects, Struts doesn't need critics, we need
models. What we need most is people like James, who create extensions,
and contribute to the codebase, and volunteer the time and energy it
takes to keep this project running, day after day.

James Mtichell is a Committer and a member of the Struts PMC. Over the
years, through his many contributions, he's earned a lot of merit with
this community. Most recently, James did the work of fixing our
nightly builds. If he did not do that work, then we might not have
nightly builds right now. James didn't do it because someone paid him
to do it. James did it because he wanted to make a difference (in a
good way).

When James speaks, I listen. Why? because James has earned a lot of
merit and credibility in my eyes.

Anyone with an email account can post to this list. But, not everyone
takes the time and energy to do the work of this project, the way
James does, and Martin does, and Don does, and Joe does, and Niall
does, and Hubert does.

Not because anyone pays them to do it (no one does), but because they
simply want to make the Struts project a better place. Not by
criticizing, but by making it so.

-Ted.

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


Re: How can I get people to look at my contribution? [was: Re: Action ...

Posted by Dakota Jack <da...@gmail.com>.
You are so totally confused and wrong about what I am about, James.  

First, the "us versus them theory" was not about what you assumed but
in fact an agreement about the "banning" policy you discussed.  You
generally seem to have very mistaken ideas about what I am doing.

I have not proposed code for Struts.  You might think I have because
you do things very differently than I do.  I would not do that
(propose such code) unless it were something like an IoC with
interfaces for the core classes.  Indeed, a lot of my griping is about
the imposition of tangential code into the Struts core.  So, I have no
gripes at all related in any way to code being or not being included
and that has never been an issue.  That is probably something that
might bother you or something.  I could care less about that.  I think
that changes are far too liberal, not too limited.  I have never
proposed a thing which I would think should be added.  You really need
to think about why you would think that.

Anyway, I really have no desire to battle you on anything at all.  I
just am a bit sensitive to people who talk down to or talk crossly
with me.  I don't put up with that.  When someone does that, I
respond.  That has nothing to do with coding, using code, blah, blah. 
I also don't care for games and general misconduct, and when I see it,
I mention it.  So do you.  We just differ on what we care about.  You
can do what you like.  I would like the same consideration.  Thanks.

Jack



On 4/24/05, James Mitchell <jm...@apache.org> wrote:
> > Whatever anyone thinks.  I am not happy that you are so agitated.
> > If I could do something sensible to help, I would.  I do think that
> > people are generally more than capable of making their own
> > decisions about what they want to read.  There is little chance
> > for competition in the arean of ideas if those in power exercize
> > that power to extinguish ideas and submissions they find a thorn
> > on their rose.
> 
> See, that's what kills me.  You are still stuck on this "us and them"
> theory.
> 
> You seem to be pretty good at creating new accounts with GMail, here's what
> you can do:
>  - go out to SourceForge.net
>  - create a new Project
>  - add all your code you've been working on that you say "those in
>    power" have been "extinguishing [your] ideas and submissions"
>  - complete any one of the projects
>  - make a release available for download
>  - make an [ANNONCEMENT] on the Struts or others mailing list
>    inviting all interested parties to try it.
> 
> The best way to provide (force) an enhancement into Struts is to
> do so through a plug-in.
> 
> If people actually use your plug-in, there will be discussion about
> it.  That's exactly what happened with many other projects.
> 
> Here's just a couple of examples:
>  - struts-menu        http://struts-menu.sourceforge.net/
>  - security-filter    http://securityfilter.sourceforge.net/
>  - struts test case   http://strutstestcase.sourceforge.net/
> 
> There are many others out there I have not even mentioned.
> 
> Here's another similar example:
> 
> Back in 2002, several people were asking if it was possible to use a
> database to store their i18n'd resource bundle instead of the default one
> provided by Struts.  So I sat down and wrote one, but ran into a few
> issues...
> 
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg40667.html
> 
> Now, what became of that idea?  Like your idea, there was not much interest
> by the committers.  Instead of whining about it, I decided to release it
> under the same License that all ASF software uses.
> 
> http://sourceforge.net/project/showfiles.php?group_id=49385&package_id=76369
> 
> I provide both the library, and a working copy of the struts-example
> modified to demonstrate it's use.  And in the years it has been available, I
> have received many thank-you emails from people I've never even heard of.
> 
> Did my contribution make it into the Struts code?  No.  Did I commit it,
> once I was asked to join the team?  No.  I followed the same procedure
> outlined above.  It's not something that enough people want, therefore it
> doesn't belong there.  And since it is so easy to use by adding a jar and
> changing your struts-config.xml, there's really no reason to add it.
> 
> --
> James Mitchell
> Software Engineer / Open Source Evangelist
> Consulting / Mentoring / Freelance
> EdgeTech, Inc.
> 678.910.8017
> AIM:   jmitchtx
> Yahoo: jmitchtx
> MSN:   jmitchell@apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


How can I get people to look at my contribution? [was: Re: Action ...

Posted by James Mitchell <jm...@apache.org>.
> Whatever anyone thinks.  I am not happy that you are so agitated.
> If I could do something sensible to help, I would.  I do think that
> people are generally more than capable of making their own
> decisions about what they want to read.  There is little chance
> for competition in the arean of ideas if those in power exercize
> that power to extinguish ideas and submissions they find a thorn
> on their rose.

See, that's what kills me.  You are still stuck on this "us and them" 
theory.

You seem to be pretty good at creating new accounts with GMail, here's what 
you can do:
 - go out to SourceForge.net
 - create a new Project
 - add all your code you've been working on that you say "those in
   power" have been "extinguishing [your] ideas and submissions"
 - complete any one of the projects
 - make a release available for download
 - make an [ANNONCEMENT] on the Struts or others mailing list
   inviting all interested parties to try it.

The best way to provide (force) an enhancement into Struts is to
do so through a plug-in.

If people actually use your plug-in, there will be discussion about
it.  That's exactly what happened with many other projects.

Here's just a couple of examples:
 - struts-menu        http://struts-menu.sourceforge.net/
 - security-filter    http://securityfilter.sourceforge.net/
 - struts test case   http://strutstestcase.sourceforge.net/

There are many others out there I have not even mentioned.


Here's another similar example:

Back in 2002, several people were asking if it was possible to use a 
database to store their i18n'd resource bundle instead of the default one 
provided by Struts.  So I sat down and wrote one, but ran into a few 
issues...

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg40667.html

Now, what became of that idea?  Like your idea, there was not much interest 
by the committers.  Instead of whining about it, I decided to release it 
under the same License that all ASF software uses.

http://sourceforge.net/project/showfiles.php?group_id=49385&package_id=76369

I provide both the library, and a working copy of the struts-example 
modified to demonstrate it's use.  And in the years it has been available, I 
have received many thank-you emails from people I've never even heard of.

Did my contribution make it into the Struts code?  No.  Did I commit it, 
once I was asked to join the team?  No.  I followed the same procedure 
outlined above.  It's not something that enough people want, therefore it 
doesn't belong there.  And since it is so easy to use by adding a jar and 
changing your struts-config.xml, there's really no reason to add it.



--
James Mitchell
Software Engineer / Open Source Evangelist
Consulting / Mentoring / Freelance
EdgeTech, Inc.
678.910.8017
AIM:   jmitchtx
Yahoo: jmitchtx
MSN:   jmitchell@apache.org




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


Re: Action call another action?

Posted by Dakota Jack <da...@gmail.com>.
<SNIP>
On 4/24/05, James Mitchell <jm...@apache.org> wrote:
...
These people are actually the same
> person masquerading as alternate identities, which would be fine if they all
> didn't have the same PITA (see below) attitudes.  
</SNIP>

You need to be careful about making these assertions, James.  

<SNIP>
> What I find really sad is that even after
> several people have explained to this guy the errors in his ways and
> actions, in cut-throat clarity, he continues to spam the lists with his
> useless defunct ideas that nobody listens to.
</SNIP>

You are obviously not happy, James.  But, you really should not let
this cloud the clear fact that many people have indicated an interest
in and an appreciation for in print.  I am not going to go through
that list, but you can easily if you like.  You won't, of course,
because you are not happy about things.

I have to tell you, however, that what you think about me is not only
none of my business but none of anyone else's business either.  That
is your business, which you have chosen to display publicly.

<SNIP>
> By the
> way, the post you sent to Struts with your Micael account was held in the
> moderation queue, which you were obviously to careless to realize.  When
> that didn't arrive to the list, you followed up with one from the Dakota
> account.  How dumb do you think we are?  Dude, you're not fooling anyone.
> Oh, it gets better.  And after all that, the only thing you managed to
> accomplish was to piss off people here and on the Cocoon list....nice job!
</SNIP>

You need to know that all these perceived complications are not part
of my life.  You have no clue what is going on.  I don't either.  I
don't in the sense that I have no idea what a "moderation" queue is. 
I also do not pay attention to when things show up on what lists. 
They really are not that big a deal to me.

<SNIP>
> This behavior has been discussed at length on and off list.  It has been
> determined that banning people who engage in this behavior has little effect
> at deterring it, and, in some cases, only adds fuel to the fire.
</SNIP>

Whatever anyone thinks.  I am not happy that you are so agitated.  If
I could do something sensible to help, I would.  I do think that
people are generally more than capable of making their own decisions
about what they want to read.  There is little chance for competition
in the arean of ideas if those in power exercize that power to
extinguish ideas and submissions they find a thorn on their rose.

Jack


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Re: Action call another action?

Posted by James Mitchell <jm...@apache.org>.
For the record, you are encouraged to ignore all statements made by Micael
McGrady, Dakota Jack, or Shey Rab Pawo.  These people are actually the same
person masquerading as alternate identities, which would be fine if they all
didn't have the same PITA (see below) attitudes.  His track record on this
list and others, has proven to be completely non-productive and, at best, a
general waste of everyone's time.  What I find really sad is that even after
several people have explained to this guy the errors in his ways and
actions, in cut-throat clarity, he continues to spam the lists with his
useless defunct ideas that nobody listens to.

It is still not known why this particular user chooses to take such drastic
measures to conceal his true identity.  The only thing worse than someone
trying to fool people by using different user accounts, is someone who is
too stupid to do it correctly.  Next time Micael, try to pay closer
attention as you participate here, other lists and TSS feedback.  By the
way, the post you sent to Struts with your Micael account was held in the
moderation queue, which you were obviously to careless to realize.  When
that didn't arrive to the list, you followed up with one from the Dakota
account.  How dumb do you think we are?  Dude, you're not fooling anyone.
Oh, it gets better.  And after all that, the only thing you managed to
accomplish was to piss off people here and on the Cocoon list....nice job!

This kind of behavior is described by the following web page:
http://wiki.apache.org/struts/DefinePita

This behavior has been discussed at length on and off list.  It has been
determined that banning people who engage in this behavior has little effect
at deterring it, and, in some cases, only adds fuel to the fire.





--
James Mitchell
Software Engineer / Open Source Evangelist
Consulting / Mentoring / Freelance
EdgeTech, Inc.
678.910.8017
AIM:   jmitchtx
Yahoo: jmitchtx
MSN:   jmitchell@apache.org




----- Original Message ----- 
From: "Shey Rab Pawo" <pa...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Saturday, April 23, 2005 2:44 PM
Subject: Re: Action call another action?


I may be mistaken but I think that the CoR (Chain of Responsibility)
pattern in Struts 1.3 is not going to be for "actions" per se
(although anyone can always use the CoR pattern) but for creating an
extensible RequestProcessor.  I may, as I said, be mistaken about
that, but the general buzz has given me that impression.

Shey Rab Pawo

On 4/21/05, Erik Weber <er...@mindspring.com> wrote:
> That's the way I do it. If your Actions are light, as they should be, it
> doesn't add a lot of code. Some redundant code is not a bad thing, it
> can make things clearer. If you were to "chain" actions, then you'd be
> going through the entire request processor chain again.
>
> I think that Struts 1.3, with chain of responsibility implementation,
> should allow chaining of actions without causing redundant processing,
> but I can't say for sure (at least I hope it does).
>
> Erik
>
>
> Yen wrote:
>
> > Hi,
> >
> > I have an action which save the data into the database, after the
> > saving, I would like to forward to the listing page, where I have
> > another action doing the listing.
> >
> > Should I repeat the same listing method (method list) in the save
> > action itself..? Or, is there any better way?
> >
> > Thanks for advanced.
> >
> > rgds,
> > Yen
> >
> > public ActionForward save(ActionMapping mapping, ActionForm form,
> > HttpServletRequest request, HttpServletResponse response)
> > {
> >    method save..
> >    method list..
> >   return (mapping.findForward("afflist"));
> > }
> >
> > public ActionForward listing(ActionMapping mapping, ActionForm form,
> > HttpServletRequest request, HttpServletResponse response)
> > {
> >    method list
> >   return (mapping.findForward("afflist"));
> > }
> >
> > ---------------------------------------------------------------------
> > 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
>
>


-- 
No one ever went blind looking at the bright side of life.

---------------------------------------------------------------------
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


Re: Action call another action?

Posted by Shey Rab Pawo <pa...@gmail.com>.
I may be mistaken but I think that the CoR (Chain of Responsibility)
pattern in Struts 1.3 is not going to be for "actions" per se
(although anyone can always use the CoR pattern) but for creating an
extensible RequestProcessor.  I may, as I said, be mistaken about
that, but the general buzz has given me that impression.

Shey Rab Pawo

On 4/21/05, Erik Weber <er...@mindspring.com> wrote:
> That's the way I do it. If your Actions are light, as they should be, it
> doesn't add a lot of code. Some redundant code is not a bad thing, it
> can make things clearer. If you were to "chain" actions, then you'd be
> going through the entire request processor chain again.
> 
> I think that Struts 1.3, with chain of responsibility implementation,
> should allow chaining of actions without causing redundant processing,
> but I can't say for sure (at least I hope it does).
> 
> Erik
> 
> 
> Yen wrote:
> 
> > Hi,
> >
> > I have an action which save the data into the database, after the
> > saving, I would like to forward to the listing page, where I have
> > another action doing the listing.
> >
> > Should I repeat the same listing method (method list) in the save
> > action itself..? Or, is there any better way?
> >
> > Thanks for advanced.
> >
> > rgds,
> > Yen
> >
> > public ActionForward save(ActionMapping mapping, ActionForm form,
> > HttpServletRequest request, HttpServletResponse response)
> > {
> >    method save..
> >    method list..
> >   return (mapping.findForward("afflist"));
> > }
> >
> > public ActionForward listing(ActionMapping mapping, ActionForm form,
> > HttpServletRequest request, HttpServletResponse response)
> > {
> >    method list
> >   return (mapping.findForward("afflist"));
> > }
> >
> > ---------------------------------------------------------------------
> > 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
> 
> 


-- 
No one ever went blind looking at the bright side of life.

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


Re: Action call another action?

Posted by Michael Jouravlev <jm...@gmail.com>.
Of course an orphaned item will sit for a while in the session. But
does not this work the same in desktop apps too? Even worse, in
pessimistic systems when you start editing you lock the record. Then
you go have your coffee to piss off colleague who needed the same
record ;-)

In my case only one item sits in the session. If it makes user
experience better and my programming easier, let it sit there. The
good thing is that this is only a memory object, a new one, database
was not called yet. And if the user won't store changes, database
never will be called (well, maybe to generate PK, yes, it will). Also,
if you "exit" from item editing to the item list, item is invalidated
and disposed. So, the only chance to leave it hanging is if the user
wanders off while "Edit Item" window is opened.

Also, I create only one instance of a "current item" for create/edit
process (per session), so at most I will have one item in the session.
No biggie. Microsoft uses extensive approach all the time and it pays.
Who remebers that Win95 needed only 4 megs?

Michael.

On 4/25/05, Adam Hardy <ah...@cyberspaceroad.com> wrote:
> On 25/04/05 17:03&nbsp;Michael Jouravlev wrote:
> > On 4/25/05, Ted Husted <te...@gmail.com> wrote:
> >
> >>>in my sample CRUD application i have editAction, which displays an
> >>>item in HTML form. It takes item ID as parameter. This action is
> >>>mapped, it can be called directly from a page using link, like
> >>>editAction.do?ID=1234. Another way to call it is to call it from
> >>>createAction, which creates new item, assigns in ID to it, and
> >>>redirects to editItem with ID attached to the URL as query parameter.
> >>>Is this chaining?
> 
> One disadvantage of this approach is that your app will create orphaned
> items whenever a user abandons the create process after hitting the
> create menu option. Your app will create a new item immediately, but the
> user may wander off and go to lunch without actually using it.
> 
> Well, I might. ;)
> 
> Adam

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


Re: Action call another action?

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
On 25/04/05 17:03&nbsp;Michael Jouravlev wrote:
> On 4/25/05, Ted Husted <te...@gmail.com> wrote:
> 
>>>in my sample CRUD application i have editAction, which displays an
>>>item in HTML form. It takes item ID as parameter. This action is
>>>mapped, it can be called directly from a page using link, like
>>>editAction.do?ID=1234. Another way to call it is to call it from
>>>createAction, which creates new item, assigns in ID to it, and
>>>redirects to editItem with ID attached to the URL as query parameter.
>>>Is this chaining?

One disadvantage of this approach is that your app will create orphaned 
items whenever a user abandons the create process after hitting the 
create menu option. Your app will create a new item immediately, but the 
user may wander off and go to lunch without actually using it.

Well, I might. ;)


Adam

-- 
struts 1.2 + tomcat 5.0.19 + java 1.4.2
Linux 2.4.20 Debian

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


Re: Action call another action?

Posted by Michael Jouravlev <jm...@gmail.com>.
On 4/25/05, Ted Husted <te...@gmail.com> wrote:
> > in my sample CRUD application i have editAction, which displays an
> > item in HTML form. It takes item ID as parameter. This action is
> > mapped, it can be called directly from a page using link, like
> > editAction.do?ID=1234. Another way to call it is to call it from
> > createAction, which creates new item, assigns in ID to it, and
> > redirects to editItem with ID attached to the URL as query parameter.
> > Is this chaining?
> 
> The question is whether you are
> 
> * going from one to the another because you need to redirect anyway, or

yes 

> * because you don't want to cut-and-paste business logic between the
> Action classes.

and yes... no, this is not entirely correct. It is not that I did not
want to cut-and-paste business logic, I did not want to cut-and-paste
UI logic. Also, because Struts action can have only one associated
form bean, it seemed natural to split one action into input (setup)
action and output action.

The understanding that redirection can provide better user experience
came later. But now I think this is a natural fit, and I develop all
my future Struts apps in the same manner. So far it works.

> If the latter, then the business API is underdeveloped and the
> application is on a slipperly slope.
> 
> The key point is: Could you call the editAction business logic from
> another Action class if need be?

Umm... Not "from". I can call it anytime, before or after other action.

> The main reason that Action Chaining is bad is because it implies
> people are not creating their own business APIs: The Action classes
> are becoming the API rather than an adaptor to the API. 

No, I am not chaining actions to load this, create that, update that
and then output that. I input data in the first action, update the
model (all business create/delete/update stuff happens here), and in
the output action I simply load business object into form bean and
display it.

> Another reason
> is simply because Struts was not designed to support Action Chaining
> and, out of the box, can't distinguish between a new request and a
> "chained" request.

This works for me, since I use redirection and I want actions to be as
independent as possible.

> The danger is allowing the Actions to become the unit of reuse. The
> business facade should be the unit of reuse.

With all due respect ;) I cannot agree with that. I reuse actions as
UI units, not business units.

> The Actions should be an
> adapter between HTTP and your application's API. There should be a
> very clear line where Struts ends and your business logic begins. As
> Steve McConnell would say: Program into Struts, not with Struts.

Right, but then again, I modularize UI units, not Struts wrappers for
my business processes.

> In this case, it should boil down to a method call on a business
> object that takes an ID and returns the value object we want to edit.
> If that is what the heart of the Action does, then the application is
> on the right road.

That what editAction does, because everything was set up before it is
called. The point is, it does not care where the object comes from. If
it is not in the memory yet, editAction loads the object from the
database.

> > This works great and allows to add a level of abstraction, so editItem
> > does not know where the data comes from. This modularized approach
> > allows to create application with high level of reuse.
> 
> As mentioned, the focus should be on the business object that editItem
> calls, not the editItem Action. The business objects should be the
> unit of reuse, and Actions merely adaptors.

As I said, I respectfully disagree. If a particular action does not
depend on exact sequence, in what other actions were called before it
to set things up, then modularizing actions can be safe and efficient.

I myself found my confession, but I would not want others to follow
commandments blindly only because they express Creator's will ;)

Michael.

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


Re: Action call another action?

Posted by Michael Jouravlev <jm...@gmail.com>.
On 4/25/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> On the subject of one Action calling another, one option that is often
> overlooked is to simply instantiate another Action yourself and call
> process() on it manually.  I.e., in Action A do:
> 
> Action ab = new ActionB();
> ab.process(m f, r, r);
> 
> The benefit to this is that you don't need to go through the request
> processing chain again, and you can determine whether you want to use the
> forward returned by the called Action (Action B above) or the one
> generated by the Action doing the calling (Action A above).

This does not work for me since redirection is a key part of my
approach to chaining. I do chaining in order to provide more robust
and friendly UI, not because I just want to reuse some business code.

Michael.

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


Re: Action call another action?

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
On the subject of one Action calling another, one option that is often
overlooked is to simply instantiate another Action yourself and call
process() on it manually.  I.e., in Action A do:

Action ab = new ActionB();
ab.process(m f, r, r);

The benefit to this is that you don't need to go through the request
processing chain again, and you can determine whether you want to use the
forward returned by the called Action (Action B above) or the one
generated by the Action doing the calling (Action A above).

Don't take this as an endorsement of this approach though, merely as an
FYI on another option.  What Ted eloquently says about a proper business
API facade should make this option irrelevent as well as the others.  But
if you have it in your head that you need/want to chain Actions, this is
another way to do it, one with some benefits that might be important to
you.  I've done this myself on occassion to no ill effect (although I
fight myself when I think of doing it now!)

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

On Mon, April 25, 2005 7:09 am, Ted Husted said:
>> in my sample CRUD application i have editAction, which displays an
>> item in HTML form. It takes item ID as parameter. This action is
>> mapped, it can be called directly from a page using link, like
>> editAction.do?ID=1234. Another way to call it is to call it from
>> createAction, which creates new item, assigns in ID to it, and
>> redirects to editItem with ID attached to the URL as query parameter.
>> Is this chaining?
>
> The question is whether you are
>
> * going from one to the another because you need to redirect anyway, or
> * because you don't want to cut-and-paste business logic between the
> Action classes.
>
> If the latter, then the business API is underdeveloped and the
> application is on a slipperly slope.
>
> The key point is: Could you call the editAction business logic from
> another Action class if need be?
>
> The main reason that Action Chaining is bad is because it implies
> people are not creating their own business APIs: The Action classes
> are becoming the API rather than an adaptor to the API. Another reason
> is simply because Struts was not designed to support Action Chaining
> and, out of the box, can't distinguish between a new request and a
> "chained" request.
>
> The danger is allowing the Actions to become the unit of reuse. The
> business facade should be the unit of reuse. The Actions should be an
> adapter between HTTP and your application's API. There should be a
> very clear line where Struts ends and your business logic begins. As
> Steve McConnell would say: Program into Struts, not with Struts.
>
> In this case, it should boil down to a method call on a business
> object that takes an ID and returns the value object we want to edit.
> If that is what the heart of the Action does, then the application is
> on the right road. If the Action goes through several lines of setup
> and teardown code, that you would not want to maintain elsewhere, then
> the application is on the road to ruin :)
>
> If it's a short road, then there may be little or no harm. But, if it
> is a long road, then there will be problems along the way.
>
>> This works great and allows to add a level of abstraction, so editItem
>> does not know where the data comes from. This modularized approach
>> allows to create application with high level of reuse.
>
> As mentioned, the focus should be on the business object that editItem
> calls, not the editItem Action. The business objects should be the
> unit of reuse, and Actions merely adaptors.
>
>
>>
>> Michael.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> --
> HTH, Ted.
>
> ---------------------------------------------------------------------
> 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


Re: Action call another action?

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
On the subject of one Action calling another, one option that is often
overlooked is to simply instantiate another Action yourself and call
process() on it manually.  I.e., in Action A do:

Action ab = new ActionB();
ab.process(m f, r, r);

The benefit to this is that you don't need to go through the request
processing chain again, and you can determine whether you want to use the
forward returned by the called Action (Action B above) or the one
generated by the Action doing the calling (Action A above).

Don't take this as an endorsement of this approach though, merely as an
FYI on another option.  What Ted eloquently says about a proper business
API facade should make this option irrelevent as well as the others.  But
if you have it in your head that you need/want to chain Actions, this is
another way to do it, one with some benefits that might be important to
you.  I've done this myself on occassion to no ill effect (although I
fight myself when I think of doing it now!)

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

On Mon, April 25, 2005 7:09 am, Ted Husted said:
>> in my sample CRUD application i have editAction, which displays an
>> item in HTML form. It takes item ID as parameter. This action is
>> mapped, it can be called directly from a page using link, like
>> editAction.do?ID=1234. Another way to call it is to call it from
>> createAction, which creates new item, assigns in ID to it, and
>> redirects to editItem with ID attached to the URL as query parameter.
>> Is this chaining?
>
> The question is whether you are
>
> * going from one to the another because you need to redirect anyway, or
> * because you don't want to cut-and-paste business logic between the
> Action classes.
>
> If the latter, then the business API is underdeveloped and the
> application is on a slipperly slope.
>
> The key point is: Could you call the editAction business logic from
> another Action class if need be?
>
> The main reason that Action Chaining is bad is because it implies
> people are not creating their own business APIs: The Action classes
> are becoming the API rather than an adaptor to the API. Another reason
> is simply because Struts was not designed to support Action Chaining
> and, out of the box, can't distinguish between a new request and a
> "chained" request.
>
> The danger is allowing the Actions to become the unit of reuse. The
> business facade should be the unit of reuse. The Actions should be an
> adapter between HTTP and your application's API. There should be a
> very clear line where Struts ends and your business logic begins. As
> Steve McConnell would say: Program into Struts, not with Struts.
>
> In this case, it should boil down to a method call on a business
> object that takes an ID and returns the value object we want to edit.
> If that is what the heart of the Action does, then the application is
> on the right road. If the Action goes through several lines of setup
> and teardown code, that you would not want to maintain elsewhere, then
> the application is on the road to ruin :)
>
> If it's a short road, then there may be little or no harm. But, if it
> is a long road, then there will be problems along the way.
>
>> This works great and allows to add a level of abstraction, so editItem
>> does not know where the data comes from. This modularized approach
>> allows to create application with high level of reuse.
>
> As mentioned, the focus should be on the business object that editItem
> calls, not the editItem Action. The business objects should be the
> unit of reuse, and Actions merely adaptors.
>
>
>>
>> Michael.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> --
> HTH, Ted.
>
> ---------------------------------------------------------------------
> 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


Re: Action call another action?

Posted by Ted Husted <te...@gmail.com>.
> in my sample CRUD application i have editAction, which displays an
> item in HTML form. It takes item ID as parameter. This action is
> mapped, it can be called directly from a page using link, like
> editAction.do?ID=1234. Another way to call it is to call it from
> createAction, which creates new item, assigns in ID to it, and
> redirects to editItem with ID attached to the URL as query parameter.
> Is this chaining?

The question is whether you are 

* going from one to the another because you need to redirect anyway, or 
* because you don't want to cut-and-paste business logic between the
Action classes.

If the latter, then the business API is underdeveloped and the
application is on a slipperly slope.

The key point is: Could you call the editAction business logic from
another Action class if need be?

The main reason that Action Chaining is bad is because it implies
people are not creating their own business APIs: The Action classes
are becoming the API rather than an adaptor to the API. Another reason
is simply because Struts was not designed to support Action Chaining
and, out of the box, can't distinguish between a new request and a
"chained" request.

The danger is allowing the Actions to become the unit of reuse. The
business facade should be the unit of reuse. The Actions should be an
adapter between HTTP and your application's API. There should be a
very clear line where Struts ends and your business logic begins. As
Steve McConnell would say: Program into Struts, not with Struts.

In this case, it should boil down to a method call on a business
object that takes an ID and returns the value object we want to edit.
If that is what the heart of the Action does, then the application is
on the right road. If the Action goes through several lines of setup
and teardown code, that you would not want to maintain elsewhere, then
the application is on the road to ruin :)
 
If it's a short road, then there may be little or no harm. But, if it
is a long road, then there will be problems along the way.

> This works great and allows to add a level of abstraction, so editItem
> does not know where the data comes from. This modularized approach
> allows to create application with high level of reuse.

As mentioned, the focus should be on the business object that editItem
calls, not the editItem Action. The business objects should be the
unit of reuse, and Actions merely adaptors.


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

-- 
HTH, Ted.

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


Re: Action call another action?

Posted by Michael Jouravlev <jm...@gmail.com>.
> When I speak of Action chaining, I mean to say a scenario where one
> action mapping's suggested forward path is not directly to a response
> generator (a JSP), but in fact to another mapped action (which will
> eventually forward to a response generator). I was advising against this
> (I know the tempation is there -- I have done it myself) because it
> causes all the dozen or so methods in the request processor "chain" to
> be executed again, redundantly in most cases, and also somewhat because
> of the "hidden" nature of the processing (which is also why I have
> avoided some genuine Struts niceties so far, but, let's face it, a
> strength of Struts is indeed declarative programming).

Ted,

in my sample CRUD application i have editAction, which displays an
item in HTML form. It takes item ID as parameter. This action is
mapped, it can be called directly from a page using link, like
editAction.do?ID=1234. Another way to call it is to call it from
createAction, which creates new item, assigns in ID to it, and
redirects to editItem with ID attached to the URL as query parameter.
Is this chaining?

This works great and allows to add a level of abstraction, so editItem
does not know where the data comes from. This modularized approach
allows to create application with high level of reuse.

Michael.

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


Re: Action call another action?

Posted by Erik Weber <er...@mindspring.com>.

Ted Husted wrote:

>On 4/21/05, Erik Weber <er...@mindspring.com> wrote:
>  
>
>>That's the way I do it. If your Actions are light, as they should be, it
>>doesn't add a lot of code. Some redundant code is not a bad thing, it
>>can make things clearer. If you were to "chain" actions, then you'd be
>>going through the entire request processor chain again.
>>    
>>
>
>I'd even go so far as to say that callling a method on a facade from
>more than one action is not redundant. Instead, I would say that it's
>a good thing and proves that the facade is well factored.
>
>Typically, I recommend that Actions be used as "transaction scripts"
>[Fowler, PEAA]. The Action should call one or more methods on a facade
>to initiate and complete the business transaction, and then select the
>appropriate response. (Which is what I believe Erik and others on this
>thread also do.)
>  
>

Yes, that is a good explanation.

>Sometimes the response needs to be created by another Action, but this
>is not what we meant when we coined the term "Action Chaining". Action
>Chaining is using more than one action to complete the business
>transction *before* selecting the response.
>  
>

When I speak of Action chaining, I mean to say a scenario where one 
action mapping's suggested forward path is not directly to a response 
generator (a JSP), but in fact to another mapped action (which will 
eventually forward to a response generator). I was advising against this 
(I know the tempation is there -- I have done it myself) because it 
causes all the dozen or so methods in the request processor "chain" to 
be executed again, redundantly in most cases, and also somewhat because 
of the "hidden" nature of the processing (which is also why I have 
avoided some genuine Struts niceties so far, but, let's face it, a 
strength of Struts is indeed declarative programming). I was imagining 
there might be a way, with the new controller, to put the request back 
through the chain but to somehow say, process X, process Y and process Z 
might be omitted, thus avoiding unnecessary processing, while letting 
process A, B, etc., occur again. This was merely a guess, and I could be 
way off, and am probably missing the point entirely as I haven't played 
with the new controller (or any of the Apache CoR stuff) yet.

> 
>  
>
>>I think that Struts 1.3, with chain of responsibility implementation,
>>should allow chaining of actions without causing redundant processing,
>>but I can't say for sure (at least I hope it does).
>>    
>>
>
>In 1.3, we are using the Commons CoR to code the request processor. As
>a result, the Request Processor is easier to customize. For more about
>that see
>
>*  http://wiki.apache.org/struts/WhyChain
>
>Developers might also want to use Commons CoR to create their own
>business facade. But   the Commons CoR can be used with *any* version
>of Struts, or any version of anything for that matter. (Heck, I'm
>using a C# port of CoR with .NET.)
>
>With CoR, it's very easy to create transaction scripts by assembling
>the scripts (or "chains") from individual commands in a chain. In the
>instant example, "save" could be one command and *list* could be
>another. The benefit is that the Action would could call the
>"Xylophone" chain without knowing that it included "save" and "list 
>*and* that you can change what commands are called by the "Xylophone"
>chain by editing the catalog XML document.
>
>For more about Commons CoR, see 
>
>*  http://jakarta.apache.org/commons/chain/cookbook.html
>
>Where CoR really shines is in the preparing rich forms that include
>multiple drop-downs and such. Each control can be populated by its own
>command. If you add or subtract a control to a page, you can edit the
>page and edit the catalog, and never touch the Action that calls the
>chain.
>
>What I really like is that I don't have to sweat the facade API.
>Before CoR, a lot of effort went into desiging the facade objects so
>that the individual methods would be easy to find (high cohesion). Now
>that the methods are individual commands, there's one less thing to
>design. :)
>
>Of course, the best part is that it's very easy to unit test the
>individual commands. If we need another drop down, I write a test and
>a command, when the test is green, I plug the command into the chain
>and add the control to the JSP. That's it.
>
>Over on dev@, the gang is getting ready to roll 1.2.7, which will
>hopefully go GA, and then we should be about ready to roll 1.3.0. We
>doubt that 1.3.0 will be GA, but we are eager to tap the keg.
>  
>

Thanks for the explanation. I will have to see some examples for it to 
sink in. I have been mainly using 1.1. I was wanting to upgrade, but 
have been waiting for 1.3 because of the major change. I'll be watching 
for the release. Please announce on this list. :)

Erik

>  
>
>>Erik
>>    
>>
>
>---------------------------------------------------------------------
>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


Re: Action call another action?

Posted by Ted Husted <te...@gmail.com>.
On 4/21/05, Erik Weber <er...@mindspring.com> wrote:
> That's the way I do it. If your Actions are light, as they should be, it
> doesn't add a lot of code. Some redundant code is not a bad thing, it
> can make things clearer. If you were to "chain" actions, then you'd be
> going through the entire request processor chain again.

I'd even go so far as to say that callling a method on a facade from
more than one action is not redundant. Instead, I would say that it's
a good thing and proves that the facade is well factored.

Typically, I recommend that Actions be used as "transaction scripts"
[Fowler, PEAA]. The Action should call one or more methods on a facade
to initiate and complete the business transaction, and then select the
appropriate response. (Which is what I believe Erik and others on this
thread also do.)

Sometimes the response needs to be created by another Action, but this
is not what we meant when we coined the term "Action Chaining". Action
Chaining is using more than one action to complete the business
transction *before* selecting the response.
 
> I think that Struts 1.3, with chain of responsibility implementation,
> should allow chaining of actions without causing redundant processing,
> but I can't say for sure (at least I hope it does).

In 1.3, we are using the Commons CoR to code the request processor. As
a result, the Request Processor is easier to customize. For more about
that see

*  http://wiki.apache.org/struts/WhyChain

Developers might also want to use Commons CoR to create their own
business facade. But   the Commons CoR can be used with *any* version
of Struts, or any version of anything for that matter. (Heck, I'm
using a C# port of CoR with .NET.)

With CoR, it's very easy to create transaction scripts by assembling
the scripts (or "chains") from individual commands in a chain. In the
instant example, "save" could be one command and *list* could be
another. The benefit is that the Action would could call the
"Xylophone" chain without knowing that it included "save" and "list 
*and* that you can change what commands are called by the "Xylophone"
chain by editing the catalog XML document.

For more about Commons CoR, see 

*  http://jakarta.apache.org/commons/chain/cookbook.html

Where CoR really shines is in the preparing rich forms that include
multiple drop-downs and such. Each control can be populated by its own
command. If you add or subtract a control to a page, you can edit the
page and edit the catalog, and never touch the Action that calls the
chain.

What I really like is that I don't have to sweat the facade API.
Before CoR, a lot of effort went into desiging the facade objects so
that the individual methods would be easy to find (high cohesion). Now
that the methods are individual commands, there's one less thing to
design. :)

Of course, the best part is that it's very easy to unit test the
individual commands. If we need another drop down, I write a test and
a command, when the test is green, I plug the command into the chain
and add the control to the JSP. That's it.

Over on dev@, the gang is getting ready to roll 1.2.7, which will
hopefully go GA, and then we should be about ready to roll 1.3.0. We
doubt that 1.3.0 will be GA, but we are eager to tap the keg.

> 
> Erik

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


Re: Action call another action?

Posted by Erik Weber <er...@mindspring.com>.
That's the way I do it. If your Actions are light, as they should be, it 
doesn't add a lot of code. Some redundant code is not a bad thing, it 
can make things clearer. If you were to "chain" actions, then you'd be 
going through the entire request processor chain again.

I think that Struts 1.3, with chain of responsibility implementation, 
should allow chaining of actions without causing redundant processing, 
but I can't say for sure (at least I hope it does).

Erik


Yen wrote:

> Hi,
>
> I have an action which save the data into the database, after the 
> saving, I would like to forward to the listing page, where I have 
> another action doing the listing.
>
> Should I repeat the same listing method (method list) in the save 
> action itself..? Or, is there any better way?
>
> Thanks for advanced.
>
> rgds,
> Yen
>
> public ActionForward save(ActionMapping mapping, ActionForm form, 
> HttpServletRequest request, HttpServletResponse response)
> {
>    method save..
>    method list..
>   return (mapping.findForward("afflist"));
> }
>
> public ActionForward listing(ActionMapping mapping, ActionForm form, 
> HttpServletRequest request, HttpServletResponse response)
> {
>    method list
>   return (mapping.findForward("afflist"));
> }
>
> ---------------------------------------------------------------------
> 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