struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Van Wart <>
Subject [SOLVED] Re: Auto render form bean as hidden fields
Date Wed, 23 Aug 2006 22:07:57 GMT
In case anyone's curious, here's the synopsis of my solution:

- Manually annotate (Java 1.5) the private fields I want to "track".
- Have a base class that stores the original state (when a record is 
first loaded from the database, for editing, for example).
- Write a class that walks through the annotated fields, getting their 
type from attributes (types are things like 
simple--hidden,text,etc--nested, or mapped), and writes <input 
type="hidden"...> tags for each one.
- Make a tag library to output the JS (exporting page context variables 
is a magical thing indeed) for checking for changes.
- Unit test for a few days :)

The tricky part was the map-based nested beans.  The easy part was 
outputting the <input type="hidden"...> tags.  The hard part was 
realizing that BeanUtils.cloneBean does a shallow copy of Maps.  
Fortunately, the code that walked through the annotations was also able 
to deep-copy the bean.

- Scott

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message