David Alves wrote:
Hi all,

I have a User object which has a Country object attached to it, representing the country that the user is from. If I do

<bean:write name="user" property="country" />

then I get the output of Country.toString(). However, say I want to call one of the other methods in country, like population. Is there an elegant way to do this? Something like

<bean:write name="user" property="country.population" />

where it would be translated behind-the-scenes into user.getCountry().getPopulation() If there's a way to do this with Struts Beans or if there's another tag library that would do it, I'd appreciate it if you could point me in the right direction. I want to avoid the use of <% %> if possible. Thanks for your time!

Without thinking about it very much, I would expect that one or other of these would work:

  <bean:write name="user" property="country.population" />
  <bean:write name="user.country" property="population" />

but failing that, JSTL would probably be the better choice:

  ${user.country.population}

No muss, no fuss. If you aren't familiar with JSTL, take an hour to learn it.

L.


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

Reply via email to