You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "chadmichael@excite.com" <ch...@excite.com> on 2006/01/27 20:49:59 UTC

using an action form if no input from page




My question concerns jsp pages that provide a read only view of data.  In other words, there won't be a form submitted from the page.  Is there a compelling reason to use an action form in these cases.  I've just been using tags such as c:out with my own beans put in scope.  I've noticed that some people use the ActionForm and jsp form tags to do this same data transfer.  That's strikes me as using the forms not necessarily in the way they were meant to be.  But I'll admit to not being entirely clear on what seems to be a simple topic, actionForms that is.  Any recommendations, with pros and cons.

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!



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


Re: using an action form if no input from page

Posted by Hubert Rabago <hr...@gmail.com>.
If the request being submitted doesn't include form values, I'd say
skip the ActionForm.

Hubert

On 1/27/06, chadmichael@excite.com <ch...@excite.com> wrote:
>
> My question concerns jsp pages that provide a read only view of data.  In other words, there won't be a form submitted from the page.  Is there a compelling reason to use an action form in these cases.  I've just been using tags such as c:out with my own beans put in scope.  I've noticed that some people use the ActionForm and jsp form tags to do this same data transfer.  That's strikes me as using the forms not necessarily in the way they were meant to be.  But I'll admit to not being entirely clear on what seems to be a simple topic, actionForms that is.  Any recommendations, with pros and cons.
>

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


Re: using an action form if no input from page

Posted by Craig McClanahan <cr...@apache.org>.
On 1/27/06, Michael Jouravlev <jm...@gmail.com> wrote:
>
> Struts best practices suggest that an action handles a request (with
> or without input data), while a JSP page is simply a data-aware HTML.
> Look at it this way: by calling an action instead of calling JSP
> directly you are asking for a resource to render itself according to
> its current state. If you called JSP directly, you would be asking to
> display a specific view of a resource, while this view may not
> correspond to resource state anymore.
>
> If you have 1:1 relationship between actions and pages, using JSP
> directly is basically the same thing, but you need to initialize your
> backing bean... sorry, your actionform or fromever you pull the data,
> anyway. This also works, if your resource can have several states, but
> views for all states are defined in one JSP page as subviews.


"render" ... "backing bean" .... hmm, those terms sound familiar :-)


The "view helper" approach described here is not popular among Struts
> users, but is used in other frameworks like Stripes.


Depends on which portion of the audience you are talking about.  Shale's
view controllers are very much aligned with the view helper design pattern,
and it's one of the standard patterns that works well for JavaServer Faces
in general.

Michael J.


Craig

Re: using an action form if no input from page

Posted by Michael Jouravlev <jm...@gmail.com>.
Struts best practices suggest that an action handles a request (with
or without input data), while a JSP page is simply a data-aware HTML.
Look at it this way: by calling an action instead of calling JSP
directly you are asking for a resource to render itself according to
its current state. If you called JSP directly, you would be asking to
display a specific view of a resource, while this view may not
correspond to resource state anymore.

If you have 1:1 relationship between actions and pages, using JSP
directly is basically the same thing, but you need to initialize your
backing bean... sorry, your actionform or fromever you pull the data,
anyway. This also works, if your resource can have several states, but
views for all states are defined in one JSP page as subviews.

The "view helper" approach described here is not popular among Struts
users, but is used in other frameworks like Stripes.

Michael J.

On 1/27/06, chadmichael@excite.com <ch...@excite.com> wrote:
>
> My question concerns jsp pages that provide a read only view of data.  In other words, there won't be a form submitted from the page.  Is there a compelling reason to use an action form in these cases.  I've just been using tags such as c:out with my own beans put in scope.  I've noticed that some people use the ActionForm and jsp form tags to do this same data transfer.  That's strikes me as using the forms not necessarily in the way they were meant to be.  But I'll admit to not being entirely clear on what seems to be a simple topic, actionForms that is.  Any recommendations, with pros and cons.

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