Caroline Jen wrote:
The Java "types" of the properties in my form bean
sometimes are not the same as those of the data fields
in my database.

The request.getParameter(); always return a String.  I
can use the copyProperties() method of the BeanUtils
to convert all the String(s) read from the web page to
proper Java "types" in my form bean.

What do I do when the property type in my form bean
does not match the data field type in my POJO bean?
You need to convert it manually... what if you have a foreign key relationship from your database? How is Struts supposed to know about that? What if it's a many-to-many relationship? Should Struts give you a list of IDs, or a list of foreign entities with all properties? You need to code this kind of relationship in the way you set up your form and process a form submission. You need to figure out a way to do the database entity->form data (key(s)=value) and form data submission (key(s)=value)->database entity. Your primary candidates of a form submission are going to be a String or a String[]. The reason why Struts doesn't give you java.lang.Long, or any other class is because you can't confidently trust the values you get from a form submission (clients can submit whatever they want, due to the disconnected nature of the net). From the look of your question, you might want to have a look at request.getParameterValues(), which returns a String[] (for multi-select lists, multiple checkboxes, etc.).

HTH

- Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to