• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing nested info via html:text

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've got an ActionForm that contains a "Bean" that contains an object with information I need to iterate on. It looks something like this:



I'm having trouble figuring out how to use <html:text> to get at the information in the Contact class:



Obviuosly this doesn't work since name is not a property of contacts. I tried to get around this using <c:set> like so:



That DOES work to populate the text box, but not when the user changes the value of the textbox and submits. Instead of getting the changes, I get the originally populated value. I'm guessing this is because <c:set> does not have the var point to the actual memory location of value and thus when the text value gets changed, it's not changing the actual bean stored in the session.

Short of redesigning the classes so there aren't 2 nested levels (which would really break my encapsulation), what can I do? Is there a JSTL or Struts tag that I can use instead of <c:set> to govern the scope of the property attribute for <html:text>?

Thanks!
Ryan
[ February 02, 2007: Message edited by: Ryan Kade ]
 
Ryan Kade
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, after searching the docs (imagine that!) I discovered the solution to my problem. For anyone else interested, from the docs for Struts "Package org.apache.struts.taglib.bean":

Bean Properties - Extended syntax to refer to JavaBean properties with simple names (same as the standard JSP tags <jsp:getProperty> and <jsp:setProperty> ) , nested names (a property named address.city returns the value retrieved by the Java expression getAddress().getCity()), and indexed names (a property named address[3] retrieves the fourth address from the indexed "address" property of a bean).

Thus, for my purposes, this should work:



And it does!

Link: http://struts.apache.org/1.2.7/api/index.html

Thanks anyway.
Ryan
[ February 02, 2007: Message edited by: Ryan Kade ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic