• 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

Actionform auto population

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where all do we use Reflection concept in java ?

Any good websites that you can point me to ?

Thanks.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic