File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Actionform auto population Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Actionform auto population" Watch "Actionform auto population" New topic
Author

Actionform auto population

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
When a property on ActionForm matches a request parameter, struts framework automatically sets the property to the value of the request paramter. How does this auto population happen ? I would like to know what happens in the background.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Struts is an open-source project--have you considered just reading the code?

If you were going to implement that kind of functionality, how do you think you might go about doing it? For instance, when I think of a simple example, letting processing a form with a "firstName" element, I'd start by thinking about what's in the request parameters: a parameter named "firstName". If I wanted to initialize an instance property, my first assumption would be that I'd look for a setter named "setFirstName()" that takes a String.

There are more details than that, but you get the idea. Plus you have access to the source code--use it!
jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
Ok ,thanks for your response... I got to know that there is something called as Reflection that's used which is responsible for the autopopulation.
jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
Where all do we use Reflection concept in java ?

Any good websites that you can point me to ?

Thanks.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

http://java.sun.com/docs/books/tutorial/reflect/

There's a whole book written about reflection (Java Reflection in Action). It's used all over the place, for a myriad of reasons.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Actionform auto population
 
Similar Threads
Nested Bean Properties
populate list property in bean
How to retrieve property and labelProperty info from action class
Best practice to get table form data back to Java beans
html:submit setter not being called