On Thu, Jan 6, 2011 at 9:41 AM, maven apache <apachemav...@gmail.com> wrote:
> 2011/1/6 Aaron Brown <aa...@thebrownproject.com>
>
> Well,is it the action's **responsibility to prepare the data which to be
> used in the view/page?
>

Yes, but in some cases it's desirable to write view code (JSP, for
example) which is not tied tightly to the underlying data. You may
want to write a generic view that works the same for many different
classes, perhaps because they're all subclasses of the same
superclass, sharing several properties in common. In this scenario,
you can have an action and a jsp that's specific to a subclass but
factor out some of the code into a generic fragment. This only works
if you can use a struts tag in the fragment without explicitly
referencing its name or type, and the easiest way to accomplish that
reliably is to push the desired object onto the top of the stack.

You certainly don't have to do it this way. None of it is required.
But this is one of many popular methodologies for creating view code
that's disconnected from the underlying controllers, and struts2 has
included things like the push tag to help support this kind of use.
Ruby on Rails has a similar construct allowing you to reference a view
fragment by passing in the default object as a parameter. Whether you
choose to do it this way or not is up to you, struts's job is just to
make this option possible.

 - Aaron

-- 
Aaron Brown : aa...@thebrownproject.com

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

Reply via email to