Sorry for confusion.  I specified to have single Form object across the
application. Actually I meant to say that I want to write a single
ActionForm class which is reusable across the application. Though each JSP
page will have its own INSTANCE of Form object with a HashMap populated with
all parameters contained in that JSP page. 

This approach speeds up the development process as I don't have to write
separate ActionForm per page. Also my struts-config.xml have very few
entries. 

But is there any disadvantage of having a single ActionForm class common to
all the pages?

Thank for your help Keith.

- Nilesh


-----Original Message-----
From: Bhattad, Nilesh [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 18, 2002 4:04 PM
To: 'Struts Users Mailing List'
Subject: RE: Single ActionServlet, ActionForm, Action across entire applic
atio n... is it ok ?

I want to keep Form object within "request" scope only.  But instead of
defining separate ActionForm class per JSP page with getters and setters, I
prefer to have a single class which has a HashMap in it.
Each JSP page will have different instance of this DynaForm object.

- Nilesh

-----Original Message-----
From: Kamholz, Keith (corp-staff) USX [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 18, 2002 3:59 PM
To: 'Struts Users Mailing List'
Subject: RE: Single ActionServlet, ActionForm, Action across entire applic
atio n... is it ok ?

Hi,
If you want to use the same form-bean for several input forms, can't you
just change the scope of the mapped actions to "session" or possibly
"application"?  I"m not sure what your needs are, but that's all I do.

~ Keith



-----Original Message-----
From: Bhattad, Nilesh [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 18, 2002 3:57 PM
To: Struts mailing list ([EMAIL PROTECTED])
Subject: Single ActionServlet, ActionForm, Action across entire
applicatio n... is it ok ?


Hello 

Recently I started working on Struts. I'm using Struts 1.0.2 version. 
Struts framework recommends to create separate ActionForm and Action object
for each JSP page.
Instead, I created a single Form object DynaForm which has a HashMap in it.
And I'm using this form object for all the JSP pages in my application. I
downloaded the Struts source. And added following lines of code in 
org.apache.struts.util.PropertyUtils::getSimpleProperty() method


if(bean instanceof DynaForm)
{
        try
        {
                return ((DynaForm)bean).getObject(name);
        }catch(Exception e)
        {
                log.debug(e.getMessage());
                return null;
        }
}

Also I have an XML file which defines the application flow

<?xml version="1.0"?>
<pageflows APP="test">
        <flow>
                <page>index</page>
                <nextpage appname="test">home</nextpage>
        </flow>
        <flow>
                <page>home</page>
                <nextpage appname="test">account</nextpage>
        </flow>
</pageflows>


All nextpage node values are defined in struts-config.xml in
<action-mappings> section. So based on this XML, I decide the application
flow from my Action object. 
I have a single Action object called as ActionHandler which is common across
the entire application.

Each JSP page is assigned to a separate Request Object which does the
business logic specific to that page. Another XML is defined for the mapping
of JSP page and Request object. Based on this XML, ActionHandler executes
exact Request object.

Now my doubts are..

1. First of all, is it advisable to change the Struts code for any reason?
In order to have a single Form object across the entire application, I did
not find any option other than changing Struts code. Is there any better way
of doing this?

2. I'm using Action object as a controller. The job of ActionHandler is to
do some generic stuff like session check, basic form validation and then
calling corresponding Request object. Is it advisable to have a single
Action object across the application? 

Please let me know your ideas on this. Thanks in advance !!


Njoy..
Nilesh

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

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

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

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

Reply via email to