If your page is read-only, then you are a lucky bastard ;-) and can
use whatever you want. Strictly speaking, you you do not have to use
ActionForm at all. I personally believe that the only value of
ActionForm class is when it is combined with <html:form> tag and you
build data entry form. This is why?

Say, you use two actions (render action and input action) and one
actionform to build a data entry form. Say you have MyForm formbean,
and it contains nested business object like Customer with properties
name and address.

Your render action displays a JSP page with <html:form> pointing to
submit action. When JSP page is rendered, Struts checks what
actionform corresponds to an action mapping referred in "action"
attribute of <html:form>. This is the same formbean that you have
prepared in your render action. Then you have say <html:text
property="name" /> and <html:text property="address" />. Struts does
the following:

* it generate HTML tags for your properties: <input type="text"
name="..." value="..."/>
* it locates a proper actionform, locates properties in it and writes
out their values to "value" attributes.
* it builds a so-called keypath for your properties, like
"MyForm.customer.name" and "MyForm.customer.address" and writes them
to "name" attributes.

Whew, render phase has finished.

Now when you submit this form, it is sent to your submit action, which
uses what a coincedence! the same actionform, MyForm. Struts processes
the request parameters that have names "MyForm.customer.name" and
"MyForm.customer.address", parses these names and sticks then into a
real Java object, which is the same Customer object nested in MyForm
actionform.

Voila, you did not have to do anything for this I/O process. This is
why having the same actionform for both render and input actions is
important. You can use one action as well if you can distinguish
between phases, usually POST for input and GET for render.

This lengthy explanation serve simply as a reasoning for actionform
usage, it works best for data entry form use case. If you have
read-only form or input-only service that does not redisplay the same
page, then you don't really need actionform. Actionform is just a Java
object that is stored in an appropriate scope by Struts for you. You
can do the same with your own beans. Ultimately all goes to servlet
container and it treats Struts actionforms or regular Java beans
equally.

Hope this helps ;-)

On 7/18/06, Mississippi John Hurt <[EMAIL PROTECTED]> wrote:
But what if my jsp page that I want to display the DAO info is a read only
page ie. doesn't have an <html:form> element on it?  Would I still populate
the ActionForm and use it to display or would I just pass a regular POJO to
jsp and use <bean:write> or jsp or scriptlet to display?

On 7/18/06, Michael Jouravlev <[EMAIL PROTECTED]> wrote:
>
> On 7/18/06, Mississippi John Hurt <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I know ActionForm can be used to transfer html-form-input-fields to the
> > Action class. But what about the other way around? Can it be used to say
> get
> > a DAO object and transfer its properties to the ActionForm, which when
> the
> > request is forwarded to a jsp, is readily available or populates the
> labels
> > on the screen.
>
> Of course. See this for some insights:
> http://wiki.apache.org/struts/StrutsManualActionClasses You can use
> one action or two actions and just one actionform. The actionform acts
> as I/O buffer.

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

Reply via email to