Understanding Form Bean Lifecycle – Struts Tutorial

Understanding FormBean Life cycle:-

Action Servlet calls various methods of formbean class as shown below:-

  • Form page submit its request to StrutsApplication.
  • ActionServlet traps and takes request.
  • ActionServlet uses Struts-config.xml file entries to decide the form bean and Action class to be used to process the request.
  • ActionServlet creates / locates form bean class object.
  • If created, ActionServlet keeps that form bean class object in the specified scope.
  • ActionServlet calls reset (-,-) of our formbean class.
  •  ActionServlet calls setxxx () methods of our form bean class to write the form data of form page to form bean class object.(form bean properties)

ActionServlet calls validate (-,-) of our form class:

If no form validition errors

ActionServlet creates / locators ,  Action class objects and calls, Execute (-,-,-) methods.

If form valadition

ActionServlet transfers the control to input page of Action class to display form validation errors. 

Form component type (form page)      Form bean property type(In form bean class)

  •              Textbox –>String / other primitive’s types
  •              Password –>String / other primitives
  •            Radio buttons –>String / other primitives

        (Grouped) (It allows selecting only one radio button as a time)

  •     Single checkbox –> String / primitives
  •     Multiple checkbox –>String []/primitives [] array

  (Ground) (Same name for all the check boxes they are allow to select multiple check boxes).

  •   Select box / combo box –>String / other primitives.

   (Allow to select only one item at a time)

  •      List box –>String []/primitives [] array

   (It allows to select multiple items at a time)

  • By giving same name for multiple radio button are can group then into single unit buts the end-user can select only one radio button at a time.
  • When multiple check boxes are grouped into a single unit by having same name for all the check boxes they allows to select multiple checkboxes as a time.

Leave a Reply

Your email address will not be published. Required fields are marked *