On Sat, 8 Dec 2001, Incze Lajos wrote:

> Date: Sat, 8 Dec 2001 00:41:07 +0100
> From: Incze Lajos <[EMAIL PROTECTED]>
> Reply-To: Struts Developers List <[EMAIL PROTECTED]>
> To: Struts Developers List <[EMAIL PROTECTED]>
> Subject: Re: FW: Opinion on design ideas???
>
> > You should note, however, that it is also possible for an Action to create
> > the view directly, if you want to:
> >
> >   public ActionForward perform(...) ... {
> >
> >     ...
> >     PrintWriter writer = response.getWriter();
> >     writer.println(...);
> >     ...
> >     return (null);
> >
> >   }
> >
> > Returning null, instead of an ActionForward instance, tells the controller
> > servlet that the response has already been created.  Of course, you could
> > do other things (like call a Velocity template) instead of writing the
> > response directly, as well.
> >
> > Thus, anything for rendering the view layer that is accessible only
> > through API calls is also usable in Struts.
> ...
> > Craig
>
> I know, I know. But: do you want to rewrite your action e.g. just because
> X team decides to change the view presentation mechanism? Clearly not.
> You really want that the action update the model and then depending on
> the result of the update operation and the current running context give
> back and abstract view to be presented.
>

Right.  That's exactly why this approach isn't emphasized.  However, I
take exception to the characterization (stated on this mailing list more
than a couple of times, not just in this thread) that it's difficult to
use Struts with things that cannot be accessed via
RequestDispatcher.forward() as the view layer.  It works fine to call your
template or whatever directly, if that's what you want to do.  Of course,
embedding println() would be silly -- but calling a template (or
triggering the rendering of an object tree using a library like ECS) might
not be so sily.

> E.g. you have some form to add a customer to your customer base. After
> the action you want to present the list of your customers. Up until
> now, you've used jdbc/jsp. Now your collegue decides to kepp the customers
> in XML file. The cheapest way now is to give the file to an xsl sheet
> to render. But the action should remain the same: update the customer list
> and give back that you'd like to render the table of current customers.
>
> Currently, in this situation you have to change your original action and
> writing the new rendering. If the actionservlet would use ActionForwards as
> facades (the same way as with Action itself) you have to write only the
> new rendering. If these renderings were general enough to be configurable
> by struts config - then you have to write nothing, just change the
> configuration. I think that's all what I was speaking about (and if
> I did not misunderstood him, Donnie Hall). It's only seems to me that
> this way it is easier to attach configurable view mechanisms to the
> framework and the coupling between the controler servlet, the user actions,
> and the rendering mechanisms would become minimal.
>

How about parameterizing the Action by including the name of the
stylesheet to execute in struts-config.xml?  There's a general purpose
"parameter" attribute in the <action-mapping> element that can be used for
stuff like this.

> That was the one side of the coin. The other is the dispatcher mechanism.
> It was only a _question_, I am really wonder, why does it count to be
> the standard, that you give the rendering to a different SERVLET.
> Is there any advantage (e.g. in the above example using an XSL servlet
> and forward to it)?

Of course, you can do this to.  For example, Cocoon can make a wonderful
rendering engine.

The only time you might consider using the Action directly is when you're
using some technology that is *not* already available via a servlet or JSP
page accessible from a forward -- such as a Velocity template, or a
dynamic image generation library, or stuff like that.

>
>
> incze
>

Craig


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

Reply via email to