You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Keith Pemberton <kb...@cox.net> on 2003/10/04 19:44:38 UTC
Must everything go through an action?...
Experts,
I'm struggling with using the View Helper pattern. In my logical way of
thinking, when a request to any jsp page is made, then the request goes to
the ActionServlet. The ActionServlet then looks up the appropriate view
helper initiallizes it with any parameters that were passed in through the
request. The ActionServlet then requests that the view helper put the
required java bean object in the request scope and then the servlet forwards
to the page that was requested. This doesn't seem to be the case, though,
with how struts works. Please correct me if I am wrong, but every link in
my jsp pages where the page that I am requesting has content that comes from
a java bean (form bean) must be linked to some action component. So, just
say that I have an index page where I am displaying only five items at a
time out of database that are ranked based on their index number in the
database. To get the next five entries from the database I would have to
use the struts tags and put an html:link element in the page that pointed to
some action class. I, guess, am just looking for an assurance that I am
implementing the view helper pattern the correct way according to struts.
Any help you can provide would be much appreciated!
Keith Pemberton
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Must everything go through an action?...
Posted by Sean Dockery <us...@sbdconsultants.com>.
It seems to me that a tiles controller can play the role of view helper. It
is definitely more convenient that writing custom tags. :-)
--
Sean Dockery
sean@sbdconsultants.com
Certified Java Web Component Developer
Certified Delphi Programmer
SBD Consultants
http://www.sbdconsultants.com
"Ted Husted" <hu...@apache.org> wrote in message
news:3F800BB7.2050002@apache.org...
> The current trend is to define two sets of Actions. One set represents
> the business actions, the client stories. This Action interacts with the
> business layer and, based on what happens, selects the next View. Back
> in the Struts 0.5 days, the ActionForward would often points to a server
> page, so the Action would, essentially, forward directly to a JSP.
>
> Most of us now find it convenient to create a second set of "View"
> Actions. These Actions work as "page controllers". Instead of forwarding
> to the JSP, we forward to these Actions instead. These Actions can then
> prepare the request with whatever "chrome" the page may need.
>
> It's a good practice to define an ActionMapping for every presentation
> page in the application, whether it's a server page or HTML, local or
> remote, even if it just forwards out to a page. If you need to add an
> Action class later, or switch in a server page for a static page, you
> can do that without changing anything else.
>
> In Strut 1.1, I find it useful to separate the business Actions and the
> view Actions into separate configuration files, and may give the View
> Actions their own virtual path. So there might be a /SelectPermitAction
> and a /view/SelectPermitAction.
>
> There is talk of adding a specific extension point for a "view Action"
> as part of the ActionForward construct, but AFAIK, no one's rolled up
> their sleeves and given it a try. This would save a trip through the
> container, and simplify cases where you want to redirect to another
> business Action.
>
> HTH, Ted.
>
> Keith Pemberton wrote:
> > Experts,
> >
> > I'm struggling with using the View Helper pattern. In my logical
way of
> > thinking, when a request to any jsp page is made, then the request goes
to
> > the ActionServlet. The ActionServlet then looks up the appropriate view
> > helper initiallizes it with any parameters that were passed in through
the
> > request. The ActionServlet then requests that the view helper put the
> > required java bean object in the request scope and then the servlet
forwards
> > to the page that was requested. This doesn't seem to be the case,
though,
> > with how struts works. Please correct me if I am wrong, but every link
in
> > my jsp pages where the page that I am requesting has content that comes
from
> > a java bean (form bean) must be linked to some action component. So,
just
> > say that I have an index page where I am displaying only five items at a
> > time out of database that are ranked based on their index number in the
> > database. To get the next five entries from the database I would have
to
> > use the struts tags and put an html:link element in the page that
pointed to
> > some action class. I, guess, am just looking for an assurance that I am
> > implementing the view helper pattern the correct way according to
struts.
> > Any help you can provide would be much appreciated!
> >
> > Keith Pemberton
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
> --
> Ted Husted,
> Junit in Action - <http://www.manning.com/massol/>,
> Struts in Action - <http://husted.com/struts/book.html>,
> JSP Site Design - <http://www.amazon.com/exec/obidos/ISBN=1861005512>.
>
> "Get Ready, We're Moving Out!!" - <http://www.clark04.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Must everything go through an action?...
Posted by Keith Pemberton <kb...@cox.net>.
Thanks so much for your answer. While I do understand everything that you
point out, I was wondering if you might have some links to documentation on
some of what you have talked about. I almost feel like this is a grave
difficency in the struts framework as to not a "standard" way of dealing
with the View Helper pattern. You know, it would be wonderful to have an
index page with dynamic content coming from a java bean and not have to
initialize that java bean by forwarding to an action that does so from a
welcome page. In other words, just have every jsp page be linked to a View
Helper so the View Helper does its work before displaying the page that is
called. From the J2EE pattens book, it seems to suggest that course of
action. (Of course, I could just be reading in what I want to). Anyway,
thanks again!
Keith
----- Original Message -----
From: "Ted Husted" <hu...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, October 05, 2003 7:16 AM
Subject: Re: Must everything go through an action?...
> The current trend is to define two sets of Actions. One set represents
> the business actions, the client stories. This Action interacts with the
> business layer and, based on what happens, selects the next View. Back
> in the Struts 0.5 days, the ActionForward would often points to a server
> page, so the Action would, essentially, forward directly to a JSP.
>
> Most of us now find it convenient to create a second set of "View"
> Actions. These Actions work as "page controllers". Instead of forwarding
> to the JSP, we forward to these Actions instead. These Actions can then
> prepare the request with whatever "chrome" the page may need.
>
> It's a good practice to define an ActionMapping for every presentation
> page in the application, whether it's a server page or HTML, local or
> remote, even if it just forwards out to a page. If you need to add an
> Action class later, or switch in a server page for a static page, you
> can do that without changing anything else.
>
> In Strut 1.1, I find it useful to separate the business Actions and the
> view Actions into separate configuration files, and may give the View
> Actions their own virtual path. So there might be a /SelectPermitAction
> and a /view/SelectPermitAction.
>
> There is talk of adding a specific extension point for a "view Action"
> as part of the ActionForward construct, but AFAIK, no one's rolled up
> their sleeves and given it a try. This would save a trip through the
> container, and simplify cases where you want to redirect to another
> business Action.
>
> HTH, Ted.
>
> Keith Pemberton wrote:
> > Experts,
> >
> > I'm struggling with using the View Helper pattern. In my logical
way of
> > thinking, when a request to any jsp page is made, then the request goes
to
> > the ActionServlet. The ActionServlet then looks up the appropriate view
> > helper initiallizes it with any parameters that were passed in through
the
> > request. The ActionServlet then requests that the view helper put the
> > required java bean object in the request scope and then the servlet
forwards
> > to the page that was requested. This doesn't seem to be the case,
though,
> > with how struts works. Please correct me if I am wrong, but every link
in
> > my jsp pages where the page that I am requesting has content that comes
from
> > a java bean (form bean) must be linked to some action component. So,
just
> > say that I have an index page where I am displaying only five items at a
> > time out of database that are ranked based on their index number in the
> > database. To get the next five entries from the database I would have
to
> > use the struts tags and put an html:link element in the page that
pointed to
> > some action class. I, guess, am just looking for an assurance that I am
> > implementing the view helper pattern the correct way according to
struts.
> > Any help you can provide would be much appreciated!
> >
> > Keith Pemberton
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
> --
> Ted Husted,
> Junit in Action - <http://www.manning.com/massol/>,
> Struts in Action - <http://husted.com/struts/book.html>,
> JSP Site Design - <http://www.amazon.com/exec/obidos/ISBN=1861005512>.
>
> "Get Ready, We're Moving Out!!" - <http://www.clark04.com>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Must everything go through an action?...
Posted by Joe Germuska <Jo...@Germuska.com>.
At 8:16 -0400 10/5/03, Ted Husted wrote:
>There is talk of adding a specific extension point for a "view
>Action" as part of the ActionForward construct, but AFAIK, no one's
>rolled up their sleeves and given it a try. This would save a trip
>through the container, and simplify cases where you want to redirect
>to another business Action.
Just for the record, as soon as I get past a deadline, I am planning
on taking a crack at this. I have a couple of unresolved questions I
posed to struts-dev, but if I get time and they haven't gotten any
feedback, I'll just fake something and let people tell me the right
way after I do it ;-)
Joe
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
"We want beef in dessert if we can get it there."
-- Betty Hogan, Director of New Product Development, National
Cattlemen's Beef Association
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Must everything go through an action?...
Posted by Ted Husted <hu...@apache.org>.
The current trend is to define two sets of Actions. One set represents
the business actions, the client stories. This Action interacts with the
business layer and, based on what happens, selects the next View. Back
in the Struts 0.5 days, the ActionForward would often points to a server
page, so the Action would, essentially, forward directly to a JSP.
Most of us now find it convenient to create a second set of "View"
Actions. These Actions work as "page controllers". Instead of forwarding
to the JSP, we forward to these Actions instead. These Actions can then
prepare the request with whatever "chrome" the page may need.
It's a good practice to define an ActionMapping for every presentation
page in the application, whether it's a server page or HTML, local or
remote, even if it just forwards out to a page. If you need to add an
Action class later, or switch in a server page for a static page, you
can do that without changing anything else.
In Strut 1.1, I find it useful to separate the business Actions and the
view Actions into separate configuration files, and may give the View
Actions their own virtual path. So there might be a /SelectPermitAction
and a /view/SelectPermitAction.
There is talk of adding a specific extension point for a "view Action"
as part of the ActionForward construct, but AFAIK, no one's rolled up
their sleeves and given it a try. This would save a trip through the
container, and simplify cases where you want to redirect to another
business Action.
HTH, Ted.
Keith Pemberton wrote:
> Experts,
>
> I'm struggling with using the View Helper pattern. In my logical way of
> thinking, when a request to any jsp page is made, then the request goes to
> the ActionServlet. The ActionServlet then looks up the appropriate view
> helper initiallizes it with any parameters that were passed in through the
> request. The ActionServlet then requests that the view helper put the
> required java bean object in the request scope and then the servlet forwards
> to the page that was requested. This doesn't seem to be the case, though,
> with how struts works. Please correct me if I am wrong, but every link in
> my jsp pages where the page that I am requesting has content that comes from
> a java bean (form bean) must be linked to some action component. So, just
> say that I have an index page where I am displaying only five items at a
> time out of database that are ranked based on their index number in the
> database. To get the next five entries from the database I would have to
> use the struts tags and put an html:link element in the page that pointed to
> some action class. I, guess, am just looking for an assurance that I am
> implementing the view helper pattern the correct way according to struts.
> Any help you can provide would be much appreciated!
>
> Keith Pemberton
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
--
Ted Husted,
Junit in Action - <http://www.manning.com/massol/>,
Struts in Action - <http://husted.com/struts/book.html>,
JSP Site Design - <http://www.amazon.com/exec/obidos/ISBN=1861005512>.
"Get Ready, We're Moving Out!!" - <http://www.clark04.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Must everything go through an action?...
Posted by Manish Singla <Ma...@Sun.COM>.
Keith Pemberton wrote:
> Experts,
>
> I'm struggling with using the View Helper pattern. In my logical way of
> thinking, when a request to any jsp page is made, then the request goes to
> the ActionServlet. The ActionServlet then looks up the appropriate view
> helper initiallizes it with any parameters that were passed in through the
> request. The ActionServlet then requests that the view helper put the
> required java bean object in the request scope and then the servlet forwards
> to the page that was requested. This doesn't seem to be the case, though,
> with how struts works.
This is exactly struts work. View helper creates presentation content, which
requires processing of dynamic business data. View Helper (Action) serve as
business data adapters. Struts try to encapsulate business logic in a helper
instead of a view to make our application more modular and to facilitates
component reuse.
> Please correct me if I am wrong, but every link in
> my jsp pages where the page that I am requesting has content that comes from
> a java bean (form bean) must be linked to some action component. So, just
> say that I have an index page where I am displaying only five items at a
> time out of database that are ranked based on their index number in the
> database. To get the next five entries from the database I would have to
> use the struts tags and put an html:link element in the page that pointed to
> some action class.
I think you mean same action class with logic ...
> I, guess, am just looking for an assurance that I am
> implementing the view helper pattern the correct way according to struts.
> Any help you can provide would be much appreciated!
>
> Keith Pemberton
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org