views:

296

answers:

1

Hi, how to use Model-driven or Object-backed approaches to map Complex Object with depth more than one. for example, I have action class with property User object and USer has a address object as its property. Address has street name as property. like .. User.address.streetName

In JSP, using s:textfield or other tags how can I represent street name.? Thanks

A: 

What is the problem with this?

<s:property value="user.address.streetName" />

In the traditional setting, this will call yourAction.getUser().getAddress().getStreetName()

And in the other way, eg. when submiting a form (jsp to Action), that would translate to yourAction.getUser().getAddress().setStreetName(param) For this to work, you just must be sure that getUser() and getAddress() do not return null (or at least that Struts can create -with empty constructor- and set that objects, IIRC).

leonbloy
Thank you. I am testing that. Is it also possible to have Objects generalized. I mean can we use Base class and Subclass concept with the JSP to Action data mapping
indra