I would like to see some examples, I have found my apps to be a bit bloated
since introducing struts and my Action classes are very small.

Thanks

-----Original Message-----
From: Sean Willson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 06, 2002 9:06 AM
To: Struts Users Mailing List
Subject: Re: Design question about ActionForm's validate method


RE: Design question about ActionForm's validate methodFor reference I wanted
to share how we are using the action framework in our web application. Every
single call to every single view on our web site goes through Struts. There
are several reasons for this, one we are using Tiles for navigation and
since they are not as tightly integrated as I would like we had to do this.
Another is that every single view has data that needs to be prepopulated
before it can be displayed. Rather than create 2 actions for each view (one
for the loading and one for the saving) we encapsulated this logic in one
action. One of the first things it does is call a method called
isSubmission(request) ... this method interrogates the request to see if
there are any parameters that it considers "new" and not related to a load,
if it found some it would then assume it is a submission. If there are none,
it assumes it is a load and thus loads all of the data from the database and
other sources. If however it sees data on the hook that it doesn't
recognize, it then behaves as a submission and attempts to perform a save.
This has worked rather well overall.

To facilitate this we create a root action that has this method
(isSubmission) and in there we can specify parameters that we want ALL
action to handle, like a successRedirect parameter that should be used in
the event a submission is successfully saved. The same can be said for a
root level form that all of our forms subclass from to tie in those
attributes added to the check in isSubmission.

Some may argue that this is a mix between the model and the controller logic
but I don't agree. I think if you look at anyone's actions you will see a
little overlap, since Struts itself isn't a pure clean line of separation.
The key is getting it to work for you and your clients while still
maintaining some future vision and control over the architecture and not
letting it get out of hand.

I you want some code examples of this I can likely throw some together.

Sean


----- Original Message -----
From: Matt Read
To: Struts Users Mailing List
Sent: Tuesday, February 05, 2002 11:59 AM
Subject: RE: Design question about ActionForm's validate method


I'm fairly new to struts (well, about 24 hours actually) and this message
touches on a concept that I've having trouble grasping.
Are you saying that your site should never allow the user to navigate to a
URL that maps to an Action unless you are submitting a form?
This is my example and although it's actually working in practice it doesn't
really feel right to me and doesn't conform to above rule. I hope I've
included enough detail and would appreciate any clues on good design.
1. User goes to the home page and clicks on a "Find a client" link.
2. This link points to "/find/client.do" which is defined as an
ActionMapping as follows:
        <action path="/find/client"
                        type="mysite.actions.FindClientAction"
                        name="clientFindForm"
                        scope="request"
                        input="/pages/findclient.jsp">
                        <forward name="newsearch"
path="/pages/findClient.jsp"/>
        </action>
3. The code in FindClientAction ensures that the user is authenticated and
then populates some request scoped attributes that enabled
/pages/findClient.jsp to function correctly. /pagesfindClient.jsp displays a
form to allow the user to enter search criteria.
4. The submit action for the form in /pages/findClient.jsp is
"/find/getresults" which is defined as an ActionMapping as follows:
    <action     path="/find/clientresults"
                        type="mysite.actions.FindClientResultsAction"
                        name="clientFindForm"
                        scope="request"
                        input="/pages/findclient.jsp">
                        <forward name="success"
path="/pages/findClientResults.jsp"/>
    </action>
5. The code in FindClientResultsAction examines the contents of the
clientFindForm and contstructs a SQL statement to retrieve the correct data.
6. /pages/findClientResults.jsp renders the results from the database.
Matt.


--
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