Just getting to grips with
Struts, so this may be a *very* basic question, but here goes:
I have a Data Transfer Object (DTO) that I want to use to pass data to the web tier, and retrieve data from it. My question involves how I should use this with struts forms. The DTO is a complex object consisting of
String fields and Collections. Something like this:
class someDTO {
private String name;
private Collection interests;
}
What approach do I take. Do I:
a) Create a struts form that holds the DTO as a member variable, looking like this:
public class MyForm extends ActionForm {
private SomeDTO someDTO;
}
This will be used to pass data to the web tier (fine, I have this working) and to pass data from the web tier back to the model. For this latter part my struts html tags access each property like this:
<html:text property="someDTO.name" />
I can't get this to work, and am now wondering if I am using the forms in the correct manner. Should I instead ...
b) Create a struts form that has values for each of the DTO fields as individual member variables, like this:
public class MyForm extends ActionForm {
private String name;
etc ...
}
The problem with this, of course, is how I reference Collections.
Basically, I'm a bit confused over the correct usage of forms in struts. And basic pointers would be much appreciated.