File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes When is form  Bean created ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "When is form  Bean created ?" Watch "When is form  Bean created ?" New topic

When is form Bean created ?

Shaan patil
Ranch Hand

Joined: Dec 22, 2007
Posts: 58

I need to know when exactly a form bean is created ?

Is it created after we submitt or before we submitt a form ?

If it is reated after we submitt a form, then How is prepopulation of fields in the form takes place ?


"You cannot change the truth but truth can change you "
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

I searched for "action form life cycle". The first hit was a clear ordered listing of the steps.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Shaan patil
Ranch Hand

Joined: Dec 22, 2007
Posts: 58

Thanks for the link. I went throught it.

If we follow the steps listed there,then How do you explain pre-populating of form fields(Default values in text fields of a form from default bean values ) when a jsp is requested ?

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This same life cycle occurs even if you just request a JSP that uses Struts tags. The first time the JSP engine encounters a Struts tag, it will initiate the ActionForm lifecycle.

Step 2 (Create or recycle ActionForm) and step 3 (call reset) is where any default values are placed into an ActionForm. If the form is in session scope and existed before this request, any values placed in the ActionForm properties by previous requests will still be there.

Consultant, Sima Solutions
I agree. Here's the link:
subject: When is form Bean created ?
It's not a secret anymore!