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 ]
Joined: Aug 16, 2005
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 retrieves the fourth address from the indexed "address" property of a bean).