RE: database - bean - form, what is the best way to do it?
When doing struts, I am always loading or saving data to a bean (or a list of beans) and then display it to the form. Is there a ways to make this process very automatic, like writing a mapping file, and then everything is done? I spent in the past 2 full days just keep doing this kind of mapping and it is getting me real crazy. Thanks Take a look at the struts-example webapp. I do this same thing in my Struts app-- load from the database into a bean, then use BeanUtils.copyProperties(...) to move the values over to the form, then display it. I use Dynamic forms, so the form properties are defined in struts-config.xml, which gets me out of writing the get/set methods for the form bean. What part of it is giving you problems? -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM
Re: database - bean - form, what is the best way to do it?
Torque allows you to define you mappings in a single xml file and you can generate all the required model classes and the sql. There are a few compromises like i haven't found that it supports inheritance do life is easier if you just have repeating fields across tables, thus not very rationalized. But really who cares, a few DBA's i guess. The inheritance could be supported, I'm still looking into it. You can use the generated classes straight into your formbeans but I've used a bean tier. And you dont have to do any SQL. So i can be more selective when to write to the db, also not doing so breaks with a lot of what struts is designed for. But you can it will make your app harder to decouple from the model, so whether this is a huge issue is down to you. Most things work with torque but I warn you its not as well documented, and list attended as well as the struts project. A bit non MVC but you can use the torque objects straight into your DynaForm definition.. form-property name=applicant type=com.sparrow.om.Applicant / Generating fields in jsp's I don't know. You could change the velocity templates to generate your beans and jsp i guess. But dont those IDE things do all that? Cheers Mark On Wednesday, August 13, 2003, at 07:02 PM, Andy Cheng wrote: Basically I am just wondering if the process can be a bit more interesting. I always: 1. Get values from the JSPs and the values (Strings) are used to set the ActionForm ie String to String copying. 2. In the Action class, I get the values from the ActionForm, and convert them to the appropriate types, and insert them into beans using the beans' setter methods. 3. From the objects I have, I will write PreparedStatements (with many ?? in the SQL), and set the values in the order of the question marks. I have to do this for INSERT, and UPDATE. On the reverse, I have to get the data from database, getting values from ResultSets, and insert into beans, then from the beans I feed them back to the JSPs for display. This is a very boring thing to do, and it does not require much skill as well. I am just wondering if there is a way of speeding up: 1. Conversion between ActionForm (Strings) to Beans (Typed) 2. Generate ActionForms 3. Generate the fields in the the JSPs 4. Generate the SQL statements. I know I am being very very greedy here, but if there is no other way than being a typist for days, I would rather write a small program to do all these. I have read Castor JDO could help generating code, but I have to read and understand more before I know if it is helping me. Thanks Andy -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2003 12:49 AM To: 'Struts Users Mailing List' Subject: RE: database - bean - form, what is the best way to do it? When doing struts, I am always loading or saving data to a bean (or a list of beans) and then display it to the form. Is there a ways to make this process very automatic, like writing a mapping file, and then everything is done? I spent in the past 2 full days just keep doing this kind of mapping and it is getting me real crazy. Thanks Take a look at the struts-example webapp. I do this same thing in my Struts app-- load from the database into a bean, then use BeanUtils.copyProperties(...) to move the values over to the form, then display it. I use Dynamic forms, so the form properties are defined in struts-config.xml, which gets me out of writing the get/set methods for the form bean. What part of it is giving you problems? -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: database - bean - form, what is the best way to do it?
this might be of help... http://jakarta.apache.org/struts/faqs/database.html -Original Message- From: Andy Cheng [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 12:44 PM To: [EMAIL PROTECTED] Subject: database - bean - form, what is the best way to do it? When doing struts, I am always loading or saving data to a bean (or a list of beans) and then display it to the form. Is there a ways to make this process very automatic, like writing a mapping file, and then everything is done? I spent in the past 2 full days just keep doing this kind of mapping and it is getting me real crazy. Thanks Andy
RE: database - bean - form, what is the best way to do it?
Basically I am just wondering if the process can be a bit more interesting. I always: 1. Get values from the JSPs and the values (Strings) are used to set the ActionForm ie String to String copying. 2. In the Action class, I get the values from the ActionForm, and convert them to the appropriate types, and insert them into beans using the beans' setter methods. 3. From the objects I have, I will write PreparedStatements (with many ?? in the SQL), and set the values in the order of the question marks. I have to do this for INSERT, and UPDATE. On the reverse, I have to get the data from database, getting values from ResultSets, and insert into beans, then from the beans I feed them back to the JSPs for display. This is a very boring thing to do, and it does not require much skill as well. I am just wondering if there is a way of speeding up: 1. Conversion between ActionForm (Strings) to Beans (Typed) 2. Generate ActionForms 3. Generate the fields in the the JSPs 4. Generate the SQL statements. I know I am being very very greedy here, but if there is no other way than being a typist for days, I would rather write a small program to do all these. I have read Castor JDO could help generating code, but I have to read and understand more before I know if it is helping me. Thanks Andy -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2003 12:49 AM To: 'Struts Users Mailing List' Subject: RE: database - bean - form, what is the best way to do it? When doing struts, I am always loading or saving data to a bean (or a list of beans) and then display it to the form. Is there a ways to make this process very automatic, like writing a mapping file, and then everything is done? I spent in the past 2 full days just keep doing this kind of mapping and it is getting me real crazy. Thanks Take a look at the struts-example webapp. I do this same thing in my Struts app-- load from the database into a bean, then use BeanUtils.copyProperties(...) to move the values over to the form, then display it. I use Dynamic forms, so the form properties are defined in struts-config.xml, which gets me out of writing the get/set methods for the form bean. What part of it is giving you problems? -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: database - bean - form, what is the best way to do it?
I believe that a general purpose web tier framework, like Struts, would not help you too much to ease the developments. A specialized product based on Struts could do much more than what you are expecting now. So you are not that *greedy* because we get it now :-) Carrier, at http://www.netspread.com, is designed to meet such demands for the Struts users. The visual designing capability allows you to compose a form bean model, a form view model (logical web form), and a form controller model in one place, called a block - an extended action mapping. It is one of the most important concept leap brought by Carrier http://www.netspread.com/tips2.html The form bean model supports 12 standard types, not only string, and custom properties. So point 1 and 2 in the always-to-do list is removed. Assume the form bean model qualifies as a level one data model, then the default persistence mechanism will help you to store and load the form bean properties automatically. So the point 3 in the always-to-do list is removed. If you have special domain models, you have to write codes to store and load your properties. The idea behind this is that non-programming designers could start to build working web applications immediately. See the tips on the Primary Form Bean. You can discover that the form bean model take care of the conversions from strings to typed properties and it could be used virtually for all form bean instances. So the point 1 and 2 in the boring-thing-to-do list could be reduced to almost zero. See the tips on One Form Bean Model for All Form Beans. The form view model allows you to general physical web forms for different browsers, devices, or whatever presentation engines using custom style sheets. The point 3 in the boring-thing-to-do list is removed. The last point (4. Generate the SQL statements) is more an O/R mapping tool's business. I definitely believe, the form bean model could be easily managed by a O/R mapping tool so the processes would be much faster. Recent studies show that over using reflections on Java beans would slow down the performance to some degree. The map based models show the faster performance. Our form bean model removes most of reflection operations, so we also get it right :-) More important is that Carrier is an enabling technology that Super Large Web Services could be built with it. A small team, 3 to 5 developers could manage a couple of thousands of testing web forms for schools teachers/students easily. The tips on Wheels and Struts can be found at http://www.netspread.com/tips-in-list.html It includes the phased validation model that people are expecting too. Jing Netspread Carrier http://www.netspread.com - Original Message - From: Andy Cheng [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 1:02 PM Subject: RE: database - bean - form, what is the best way to do it? Basically I am just wondering if the process can be a bit more interesting. I always: 1. Get values from the JSPs and the values (Strings) are used to set the ActionForm ie String to String copying. 2. In the Action class, I get the values from the ActionForm, and convert them to the appropriate types, and insert them into beans using the beans' setter methods. 3. From the objects I have, I will write PreparedStatements (with many ?? in the SQL), and set the values in the order of the question marks. I have to do this for INSERT, and UPDATE. On the reverse, I have to get the data from database, getting values from ResultSets, and insert into beans, then from the beans I feed them back to the JSPs for display. This is a very boring thing to do, and it does not require much skill as well. I am just wondering if there is a way of speeding up: 1. Conversion between ActionForm (Strings) to Beans (Typed) 2. Generate ActionForms 3. Generate the fields in the the JSPs 4. Generate the SQL statements. I know I am being very very greedy here, but if there is no other way than being a typist for days, I would rather write a small program to do all these. I have read Castor JDO could help generating code, but I have to read and understand more before I know if it is helping me. Thanks Andy -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2003 12:49 AM To: 'Struts Users Mailing List' Subject: RE: database - bean - form, what is the best way to do it? When doing struts, I am always loading or saving data to a bean (or a list of beans) and then display it to the form. Is there a ways to make this process very automatic, like writing a mapping file, and then everything is done? I spent in the past 2 full days just keep doing this kind of mapping and it is getting me real crazy. Thanks Take a look at the struts-example webapp. I do this same thing in my Struts app-- load from the database into a bean, then use