Hi,
When i submit a form, it is not calling the method "onSubmitAction" of the respective simpleformcontroller.
Definition of SimpleFormController in application-portlet.xml as below
The EmployeeInfo.jsp as belowCode:<bean id="submitEmployeeInformation" class="com.jpmorgan.employee.controller.SubmitEmployeeInformation" parent="employeeControllerTemplate"> <property name="sessionForm" value="true"/> <property name="commandName" value="employee"/> <property name="commandClass" value="com.jpmorgan.employee.model.Employee"/> <property name="formView" value="EmployeeInfo"/> <property name="validator" ref="empValidator" /> </bean>
The SimpleformController class as belowCode:<%@ include file="/WEB-INF/jsp/include.jsp" %> <div class="portlet-section-header">Enter Your Information</div> <div class="portlet-section-body"> <portlet:actionURL var="actionUrl"> <portlet:param name="action" value="showSuccess"/> </portlet:actionURL> <form:form commandName="employee" method="post" action="${actionUrl}"> <div><form:errors cssClass="portlet-msg-error" /></div> <table border="0" cellpadding="4"> <tr> <th class="portlet-form-field-label">Name :</th> <td><form:input cssClass="portlet-form-input-field" path="name" size="30" maxlength="80" /></td> <td><form:errors cssClass="portlet-msg-error" path="name" /></td> </tr> <tr> <th class="portlet-form-field-label">Age :</th> <td><form:input cssClass="portlet-form-input-field" path="age" size="30" maxlength="80" /></td> <td><form:errors cssClass="portlet-msg-error" path="age" /></td> </tr> <tr> <th colspan="3"><button type="submit" class="portlet-form-button">Submit Me</button></th> </tr> </table> </form:form> </div> <div class="portlet-section-footer"> </div>
Code:package com.jpmorgan.employee.controller; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.PortletRequest; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import org.springframework.validation.BindException; import org.springframework.web.portlet.ModelAndView; import org.springframework.web.portlet.mvc.SimpleFormController; import com.jpmorgan.employee.model.Employee; public class SubmitEmployeeInformation extends SimpleFormController { @Override public void onSubmitAction(ActionRequest request, ActionResponse response, Object command, BindException errors) { Employee employee = (Employee) command; System.out.println("Name of the Employee:"+ employee.getName()); System.out.println("Age of the Employee:"+ employee.getAge()); response.setRenderParameter("action","showSuccess"); } @Override protected Object formBackingObject(PortletRequest request){ Employee employee = new Employee(); return employee; } @Override protected ModelAndView renderInvalidSubmit(RenderRequest request, RenderResponse response) { return null; } @Override protected void handleInvalidSubmit(ActionRequest request, ActionResponse response) { response.setRenderParameter("action","submitempinfo"); } }
When i submit, it is not calling OnsubmitAction instead the control is going to formBackingObject.
I dont know where i am making the mistake.
Thanks in advance for the help.
Lakshmi.


Reply With Quote