Announcement Announcement Module
Collapse
No announcement yet.
Duplicate form submission when using form bean as an instance variable in controller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Duplicate form submission when using form bean as an instance variable in controller

    hello,

    I am stuck up with a weird problem.

    Problem: The form gets submitted twice, when using the form bean as an instance variable to the controller.

    Description:
    I am using MultiActionController and there are a few objects that I have to keep in session, so I chose to inject the form bean as an instance variable in the controller. I have overridden the newCommandObject method, which will return the instance variable.
    When I click on the submit button the first time, the form gets submitted fine.
    The next time I click submit, the form gets submitted twice.
    Every alternate click produces "2 form submission".

    There are 4 submit buttons in the screen. Regardless of what button I click, duplicate form submission occurs.

    Help: Please let me if I am doing the right thing by injecting the bean as an instance variable. If not, is there a way I can keep the form (with object attribute values ) in session ?

    I am using spring 1.2, so can't use scoped beans.

    Here is code extract

    Code:
    Controller:
    public class XController extends MultiActionController
    {
    	private ApplicationSummaryBean applicationSummaryBean;
    
     	protected Object newCommandObject(Class arg0) throws Exception
        	{
    		if(applicationSummaryBean.getSomeList() == null)
    		{
    			applicationSummaryBean.setSomeList(service.getBusinessList());
    		}
            	return applicationSummaryBean;
        	}
    
     	public ModelAndView submitApplication(HttpServletRequest request,
                HttpServletResponse response, ApplicationSummaryBean command)
        	{
    		System.out.println("in submit");
    		..........some processing
    		return modelAndView;
    	}
    
    	public ModelAndView otherMethods(HttpServletRequest request,
                HttpServletResponse response, ApplicationSummaryBean command)
        	{
    		return modelAndView;
    	}
    }
    
    config.xml
    <bean id="xcontroller"
    		class="com.xxx.xxxx.xController">
    		<property name="methodNameResolver"
    			ref="xmethodNameResolver" />
    		
    		<property name="applicationSummaryBean"
    			ref="applicationSummary" />
    	</bean>
    <bean id="applicationSummary"
    		class="xxx.xxxx.ApplicationSummaryBean"
    		singleton="false">

  • #2
    please help....

    Comment

    Working...
    X