PDA

View Full Version : Web Form


mayank76
Aug 10th, 2007, 05:28 PM
not an issue

Jörg Heinicke
Aug 11th, 2007, 04:55 PM
I do not really understand your questions. The idea of PropertyEditors is to convert a value to string and back. If your record fields are only of default types (http://static.springframework.org/spring/docs/2.0.x/reference/validation.html#beans-beans-conversion) you don't need to do anything with them. It might be different for the drop-down since you might need to convert a record to a string directly, not only one of its fields. In this case you can use a PropertyEditor.

Joerg

bodhost.com
Aug 12th, 2007, 01:42 AM
Mayank,

Can you please explain in detail. You can mention them in points perhaps and we can eventually understand your concept. :)

Jörg Heinicke
Aug 13th, 2007, 10:08 PM
Ok let’s say I have a record with following layout and appears multiple times on the page (like a table structure). How should I design my form..?

This is a very common use case. You have a form-backing object which holds a list of your records. In the JSP (or template language of your choice) you iterate over the list and create the rows in the table.

Also, let say I want to display a list of countries in column2 (country object) and I have a customcountryEditor to convert from object to string. Now if I have 2 records on the page, can I use same countryEditor to bind column2 of record 1 and record2.

Of course. You register your CustomCountryEditor for type Country.class or something like this and it works.

Joerg

bodhost.com
Aug 14th, 2007, 09:07 AM
This is a very common use case. You have a form-backing object which holds a list of your records. In the JSP (or template language of your choice) you iterate over the list and create the rows in the table.



Of course. You register your CustomCountryEditor for type Country.class or something like this and it works.

Joerg

I agree, thats pretty fine. I dont have much knowledge but you can try the Country.class, thats a nice solution. :)

Jörg Heinicke
Aug 14th, 2007, 03:35 PM
Thanks..I got it to work.

I wonder if you really custom editor. What's actually the command object? commandForm or command? I'm confused by your code. Also consider using more advanced Spring's form taglib. This would reduce your code to 1 line.

Once I display my form page for edit, user can add another row ( let say through javascript). How can I dynamically modify my command object on form submission. Can I use interceptor before controller to map and populate this additional row in command object..?

Interceptor might work. The easiest solution is probably to use a lazy-initialized collection (http://commons.apache.org/collections/api-release/org/apache/commons/collections/list/LazyList.html) though.

Joerg