This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes LazyValidatorForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "LazyValidatorForm" Watch "LazyValidatorForm" New topic


Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

I'm working on an existing application that uses Struts 1.3.8. Throughout the code the original developer used LazyValidatorForm and he built these assembler classes that takes a LazyValidatorForm and a JavaBean and sets the bean properties into the LazyValidatorForm object. So something like:

And then in the jsp you'd have something like:

Some of this assembler code is hundreds of lines long depending on the complexity of the model being used in the form. Is there a better/simpler way to do this? I haven't had to mess with struts in years so I am a bit rusty but I don't remember ever having to do this.
[ October 01, 2008: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I personally never used LazyValidatorForm largely because of the issue you raised that they require a lot of ugly code to get data into and out of such a bean. I doubt, though, that it would be worth refactoring the application unless you're doing major revisions to it anyway.

If I were writing such an application from scratch, I'd just code regular JavaBeans that extend ActionForm and then use Apache Commons BeanUtils to copy the properties to and from the model objects. I don't believe that the BeanUtils copyProperties method will work on a LazyValidatorForm.

Consultant, Sima Solutions
I agree. Here's the link:
subject: LazyValidatorForm
Similar Threads
Accessing nested info via html:text
text area +populating with default value
how to use java.util.Calendar in S2
Can EL access the errors object
how to nest Struts tags?