You can access the properties of the form bean by using jsp:bean or just do

<%
        // if the bean was submitted in request scope.
        formBean asdf = request.getAttribute("the key you used - or name attribute
of youe struts form tag.");
%>

even if the validation failse and you used request, your bean properties
will be preserved.

Thank you.

Jason H. Kim
Quatrix Emerging Technology Team
Phone: 314-993-5858 EXT: 137

-----Original Message-----
From: Ned Seagoon [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 20, 2001 5:48 AM
To: [EMAIL PROTECTED]
Subject: help! confused over forms and errors and oooh, other stuff :-)


Hi Guys,

I wonder if you could help me out a little please? I am in the middle of
developing a proof of concept app with struts. If this comes off the company
could migrate away from a proprietary framework to struts, which I am in
favour of.

I seem to have confused myself over an issue regarding validation and forms.
I’ll give a simplified workflow as an example.

We have for all intents and purposes a generated product overview page along
these lines:

*Wooden Throat Mallet        59.95 >buy<
*Leather Uncle Frightener    12.60 >buy<
*Vandal-Proof Toupee         99.99 >buy<

Which is generated from struts tags. The >buys< are links to a pages which
look something like ‘buyit.do?itemid=50’. The buyit.do action has registered
a form in request scope. During processing, it looks up the full details of
the itemid and places the resulting bean in request scope. It then creates
the form object, populates it with some default information and sets this in
the request too before forwarding onto buypage.jsp

This displays the details of the item, and contains a form for entering,
say, credit card details:

*Item: Vandal-Proof Toupee
*Manufacturer: Lockheed-Martin Advanced Hairpiece Research
*Price: 99.99
*Additional Information: Also Invisible to Radar
*
* Inside Leg Measurement: _____
* Credit Card Number: ____________________
* >BUY< {forwards onto checkout.do}

Which is all fine and dandy and displays correctly. Though what happens if
the form validate fails? If checkout.do has an ‘input’ attribute which is
buypage.jsp then this will fail because the item details are stored on the
request has not been set up (it was done in ‘buyit.do’). I could of course
set the item details on the session, but if the user opened new browser
windows for the ‘buyit’ link, then the session level object will be
overwritten.

If have looked into placing the details object onto the form bean as it is
populated, but will that property be preserved across a validate failing?
And how do I get at the properties of the form bean outside of the
<hmtl:xxx> tags?

Help !

Regards
Ned



_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Reply via email to