In this case, it's possible that you need an "InputRecord" Action with
validation=false. If this uses the same ActionForm as CreateRecord, it
will create a blank form in the request, but not try to validation it. 

This is a good place to use a "ContinueAction" that just forwards the
request along, creating the form bean on the way. There is a
ContinueAction in Scaffold, but the implementation is quite simple. 

        return mapping.findForward(request.getParameter("continue"));

You would then just create a mapping for "InputRecord" that used the
ContinueAction type, whatever ActionForm you need, validate set to
false, and forwarded to your JSP. You can use this same Action whenever
a blank form needs to be created.

If you link directly to the JSPs, then you cannot move the JSPs around
without editing them all. A system implementation detail has been
embedded in the view. 

If you always link through Actions, or global forwards, then all the JSP
paths are in the Struts config. You can substantially "rewire" the
application without touching JSP or Action source code. 

Another thing to watch for, is that, in some cases, when validation fail
the input property needs to go back through an Action to restore some
Java-request objects that were lost in the HTTP-request. This often
happens in the context of drop-down boxes and the like.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/


"T. Wheeler" wrote:
> 
> Hello,
> 
> I am still getting up to speed on struts and might be missing something
> quite obvious.  I have read on Ted Husted's site that (to paraphrase) you
> should *not* link to .jsp pages, but instead link to the Actions.  Ted even
> goes so far as to suggest putting .jsp pages beneath WEB-INF/ so they are
> not available to be requested directly by clients.
> 
> I can understand his reasoning, however, I have a practical question.  First
> I must give a little background:
> 
> I am developing a very simple CRUD app, and am working on the Create
> portion.  When a user clicks a link for "Create Record" it links to
> /createRecord.do.  The user should be able to fill out the page, and then go
> to the next action /createRecordConfirm.do, where the values are shown but
> not editable.  From /createRecordConfirm.do, the user can either click the
> "Create" button to add a new record, or click the "back" button and go back
> to the form and make changes, then continue on as described.
> 
> This createRecord.do action has a bean which includes validate(), since I
> want to show validation errors to the user for correction as soon in the
> process as possible.  However, when the user first clicks the link for
> /createRecord.do, the bean's validate() method throws a bunch of errors,
> since the form has not yet been filled out.  Is there a way to check for a
> totally blank form ( if form == null doesn't work ) or some better way to do
> this?  Or should I just link directly to the JSP, since this works as I need
> it to.
> 
> Also, if someone knows of a good (and easy to install) example CRUD app, I
> would love to see it.  I was not able to install artimus (database problems)
> and sonic doesn't seem to do things the *correct* way (they link directly to
> JSPs).
> 
> Thanks!
> 
> Tom
> 
> --
> 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