Struts2 xwork Type Conversion - Multiple different parameters into one Object
Is it possible to convert different paremeters into one object on your action?
Say from my html form, I pa开发者_StackOverflowss in variables, "firstname", "lastname". Can I write a type converter that will convert those into a Person object on my action?
I didn't see any examples of this, and I don't see API. I don't see how I can access the value stack in the StrutsTypeConverter to get to the other variables.
Thanks!
Example :
// JavaBeans
public class Person {
@Getter @Setter private String firstname;
@Getter @Setter private String lastname;
}
// Action
@Setter private Person person;
// form
<s:form>
<s:textfield name="person.firstname" />
<s:textfield name="person.lastname" />
</s:form>
Similar example : vaannila : Domain Object as JavaBeans Property
I am agree what lschin said.you can use the build in OGNL and value stack combination to achieve what you want.still if u need some specific type conversion machanism here are the details from the Struts2 docs
Struts2 Type Conversion
精彩评论