when is container going to call formBackingObject in controller?

 i mapped MyObjectForm.html to AddEmployeeFormController;

 when i access the application with this url http://localhost/springapp/MyObjectForm.html i assume that it will call formBackingObject in AddEmployeeFormController but it's not happened like that;nothing is called in that controller;when is container going to call formBackingObject in controller?


configuration file
******************

  <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
            <props>
                    <prop key="/test.html">viewController</prop>
                <prop key="/MyObjectForm.html">empForm</prop>
            </props>
        </property>
    </bean>

     <bean id="empForm" class="web.AddEmployeeFormController">
        <property name="sessionForm"><value>true</value></property>
        <property name="commandName"><value>myobject</value></property>
        <property name="commandClass"><value>bus.Employee</value></property>
   <!--   when i call first time emp.htm it will call formBackingObject intrun formView should match  /emp.htm-->
        <property name="formView"><value>MyObjectForm</value></property>
        <property name="successView"><value>test.html</value></property>
        <property name="empObjectDaoImpl"><ref bean="empObjectDaoImpl"/></property>

   </bean>

 
   
   
   controller
******************
   
   protected Object formBackingObject(HttpServletRequest request) throws
            ServletException {


                    System.out.println("Entering formBackingObject AddEmployeeFormController  ....");

        String id = request.getParameter("id");
        if (null != id && !id.equals("")) {
            Employee emp = (Employee) empObjectDaoImpl.findMyObjectById(Integer.parseInt(id));
            System.out.println("formBackingObject  AddEmployeeFormController IF id is not null====="+emp);

                  return emp;
        }
        return new Employee();
    }

    jsp
    ***

    <tr>
  <td colspan="5"><a href="MyObjectForm.html">Click here to add new Object</a></td>
</tr>
LVL 20
chaitu chaituAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mick BarryJava DeveloperCommented:
what are your mappings?
Mick BarryJava DeveloperCommented:
>  <!--   when i call first time emp.htm it will call formBackingObject intrun formView should match  /emp.htm-->
 
does this mean that you have emp.htm mapped to your form controller?
If so thats the url you should have in your link

  <td colspan="5"><a href="emp.htm">Click here to add new Object</a></td>
chaitu chaituAuthor Commented:
sorry i have not seen properly  its calling formBackingObject when i type http://localhost:9090/springapp/MyObjectForm.html;

my question is when is container going to call formBackingObject in controller?
at what situations will it call
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

chaitu chaituAuthor Commented:
<td colspan="5"><a href="MyObjectForm.htm">Click here to add new Object</a></td>

it is mapped to AddEmployeeFormController  ;;
Mick BarryJava DeveloperCommented:
it will get called for a new form

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chaitu chaituAuthor Commented:
i think except for submit buttons it will call all times ;;
Mick BarryJava DeveloperCommented:
> i think except for submit buttons it will call all times ;;

depends if its a GET or a POST
Mick BarryJava DeveloperCommented:
A GET is a request for a new form
A POST would check the session for existing form
chaitu chaituAuthor Commented:
if it is POST it will not call formBackingObject ;
what is the meaning of this         <property name="sessionForm"><value>true</value></property>

 <bean id="empForm" class="web.AddEmployeeFormController">
        <property name="sessionForm"><value>true</value></property>
        <property name="commandName"><value>myobject</value></property>
        <property name="commandClass"><value>bus.Employee</value></property>
          <property name="formView"><value>MyObjectForm</value></property>
        <property name="successView"><value>test.html</value></property>
   
   </bean>
Mick BarryJava DeveloperCommented:
Indicates whether the form object should be kept in the session when a user asks for a new form.
chaitu chaituAuthor Commented:
i think only few experts good in spring;
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.