Thanks Michael and Michael for your suggestions. Yes they all work and it might come down to the question what I really want -- or to the question about best practices and design guidelines when modularising an application.
On 29 Mar 2006 at 9:16, Michael Peters wrote: > > Well, I could output a minimal response with a redirect header but that > > would make the > > forward somewhat external and would make the whole thing even slower > > because then the > > click on 'submit' would cause two complete request/response cycles with > > Application > > initialisation and everything until the user gets some response. > > Well, it depends. If you need 2 complete cycles (setup, init, prerun, > postrun, etc) then using an external redirect isn't a bad option. I don't need the 2 complete cycles but they might be the price for a clean solution. Perhaps a little background. For every form in my application I have two runmodes, one to display the form and one to process the submitted form, in most cases this will save a record to the database. Now I don't want to show a "Thank you for saving this record"-page but instead forward the user to a menu-like main page. And this main page is not in one of the record-related sub- apps but in its own "central pages"-app. How do others design their apps to deal with this common case? Shouldn't one do a forward after any "save"-action anyway? I don't quite understand the reason but I think I remember it from a former discussion on this list. > 1) You could call the other method in the other class as if it were a > method on the current object. > > return Other::App::run_mode($self); > > This has problems if the other run mode uses methods in the Other::App > class. > > 2) You could create a new instance of the other application and run the > other mode. > > my $other_app = Other::App->new( QUERY => $self->query ); > return $other_app->run_mode(); Both of these solutions work and also Michael Graham's blessing into the other app but they all look a little bit hackish. But by reading your replies I think I came to a possible solution myself: If the redirection is to a central page then mirror this relationship in the inheritance tree, let every record-oriented sub-app inherit from the central-pages-sub-app. And then the central runmodes are local again. This is more or less a clean variant of Michael Graham's "bless-into-the-other-app" suggestion. Thanks for listening to me, it really helped moving my brain into the right direction! (But I am still interested to hear how others design their application-tree) Michael --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[email protected]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
