0

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

Matt
  • 74,352
  • 26
  • 153
  • 180
indra
  • 35
  • 5

1 Answers1

1

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
  • 73,180
  • 20
  • 142
  • 190
  • 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 Jun 09 '10 at 05:30