This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hi I'm returning an com.test.Account object from a database and need to display it on the page. I've set up a dynaForm and given it 1 property -account - with a type of com.test.Account. The user can then edit the data and submit the form. My question is follows: Is it better to create forms to match your object(have getter and setters for each field) or can you do it like I did above and reference the field in the JSP page like - account.accountnumber?? The issue I see with doing it the second way is when the user resubmits the form, how does Struts automatically populate the form if you don't have each field listed in the form?
If you have a bean in a form, struts will match request names like account.accountnumber with the setAccountnumber() setter method on the 'account' bean that it gets from the formbean's getAccount() getter. I actually did a whole project like this. Most of my formbeans contained 2 or 3 properties only, one of which was another bean, a value bean, containing the data that the user would see. Seemed more logical and fitted the MVC design pattern better, I thought, although I never asked the big boys on the struts-user list what they thought.
I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.