With struts the form beans capture all state relating to a form. Or at least
that's how I think it's designed.
Now, I can see how this is appropriate when you want to redisplay the form
to the user when there are errors and want to keep all the original values
intact. ie. sticky values.
What I want to know is ... how do things get from a database into a form
bean?
When allowing the the user to view/modify contents of a record you'll use a
form bean to capture the displayable/editable state of the record so does
that mean that you also have to take the data from the database and put it
into a form bean? This is easy for textfields. If you have checkboxes/select
lists what does your .jsp code look like? For every option you have to pass
it's value and compare against the beans value right?
I will not use struts as I'm working on an ongoing project but I have some
input in how I handle my form processing. The team already puts all form
processing in jsp pages and I'm using servlets.
So, if I have everything understood correctly I'm gonna have write my code
like this.
I will want to browse a record and allow the user to make changes.
So my form will be written to query it's layout based on the state of the
form bean. So I'll populate said bean in my servlet that reads the database
for the selected browsed record put that into the request as a request
attribute and my form will conditonalize it's layout values based on the
contents of the form bean . In addition my form will also have to use
setProperty: on the form bean from the request attributes so that it can
redisplay the new values after I dispatch from my form's handling servlets
correct. At all times the form queries the form bean for it's values and I'm
just trying to get my head around how the form bean gets those values
1. When read from the database.
I have to explicitly configure the formbean from these values.
2. When edited in the from.
I use setProperty to that the beans properties are automatically set from
the request attributes.
Q. Since I'm using 1 and 2. The initial request to display the form won't
have any request parameters as I'm setting a request attribute ie. the form
bean and populating the form via that. My beans properties won't be
overwritten by the setProperty in the form right? ie. if there's no
parameters in the request my form bean will come through untouched by
setProperty right?
Am I making sense?
This sounds feasible right?
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets