Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: onSubmitAction not getting called - Portal

  1. #1

    Default onSubmitAction not getting called - Portal

    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

    Code:
    <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 EmployeeInfo.jsp as below

    Code:
    <%@ 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>
    The SimpleformController class as below

    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.

  2. #2

    Default

    Hi All,

    Kindly update me if inputs..

    Thanks,
    Lakshmi.

  3. #3
    Join Date
    Aug 2004
    Location
    Norwalk, CT USA
    Posts
    27

    Default

    I think there is no need of overriding formBackingObject method as by default it returns an instance of the commandClass that has been configured.
    Ritesh

  4. #4

    Default

    Hi,

    Thanks, I have commented formBackingObject.
    Still when i submit the page, why control is not going to onSubmitAction().

    Any idea?

    Thanks,
    Lakshmi.

  5. #5
    Join Date
    Aug 2004
    Location
    Norwalk, CT USA
    Posts
    27

    Default

    Can you share your configuration for PortletModeParameterHandlerMapping?
    Ritesh

  6. #6

    Default

    Hi,

    Please find below PortletModeParameterHandlerMapping config.

    Code:
    <!--  URL mappings Start-->
        <bean id="portletModeParameterHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping">
       		<property name="interceptors">
    			<list>
    				<ref bean="parameterMappingInterceptor"/>
    			</list>
    		</property>
     		<property name="portletModeParameterMap">
    			<map>
    				<entry key="view">
    					<map>
    						<entry key="employeeMain"><ref bean="employeeMainController"/></entry>
    						<entry key="submitempinfo"><ref bean="submitEmployeeInformation"/></entry>
    						<entry key="showSuccess"><ref bean="showSuccessController"/></entry>
    					</map>
    				</entry>
    			</map>
    		</property>
    	</bean>		
    
    	<bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
            <!-- <property name="order" value="20"/> -->
    		<property name="interceptors">
    			<list>
    			</list>
    		</property>
    		<property name="portletModeMap">
    			<map>
    				<entry key="view"><ref bean="employeeMainController"/></entry>
    			</map>
    		</property>
    	</bean>
    Let me know if you need any more info.

    Thanks,
    Lakshmi.

  7. #7
    Join Date
    Aug 2004
    Location
    Norwalk, CT USA
    Posts
    27

    Default

    In JSP, value of action is 'showSuccess' and in mapping configuration this is mapped to showSuccessController bean. I think it should be mapped to submitEmployeeInformation.
    so it should be:

    <entry key="employeeMain"><ref bean="employeeMainController"/></entry>
    <entry key="submitempinfo"><ref bean="submitEmployeeInformation"/></entry>
    <entry key="showSuccess"><ref bean="submitEmployeeInformation"/></entry>
    Ritesh

  8. #8

    Default

    Hi,

    I have modified the JSP like below.

    Code:
    <div class="portlet-section-body">
    	
    	<portlet:actionURL var="actionUrl">
    		<portlet:param name="action" value="submitempinfo"/>
    	</portlet:actionURL>
    And the mapping stays same.

    Code:
    <!--  URL mappings Start-->
        <bean id="portletModeParameterHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping">
       		<property name="interceptors">
    			<list>
    				<ref bean="parameterMappingInterceptor"/>
    			</list>
    		</property>
     		<property name="portletModeParameterMap">
    			<map>
    				<entry key="view">
    					<map>
    						<entry key="employeeMain"><ref bean="employeeMainController"/></entry>
    						<entry key="submitempinfo"><ref bean="submitEmployeeInformation"/></entry>
    						<entry key="showSuccess"><ref bean="showSuccessController"/></entry>
    					</map>
    				</entry>
    			</map>
    		</property>
    	</bean>

    Still it is not calling the onSubmitAction().

    Thanks again for your help.

    Lakshmi.

  9. #9
    Join Date
    Aug 2004
    Location
    Norwalk, CT USA
    Posts
    27

    Default

    Ok. could you please try following:

    1. Add portlet mode:
    Code:
    <portlet:actionURL var="actionUrl" portletMode="view">
    		<portlet:param name="action" value="submitempinfo"/>
    	</portlet:actionURL>


    2. add order as 1 to parameter mapping:
    Code:
    <bean id="portletModeParameterHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping">
    		<property name="order" value="1"/>
       		<property name="interceptors">
    			<list>
    				<ref bean="parameterMappingInterceptor"/>
    			</list>
    		</property>
     		<property name="portletModeParameterMap">
    			<map>
    				<entry key="view">
    					<map>
    						<entry key="employeeMain" value-ref="employeeMainController"/>
    						<entry key="submitempinfo" value-ref="submitEmployeeInformation"/>
    						<entry key="showSuccess" value-ref="showSuccessController"/>
    					</map>
    				</entry>
    			</map>
    		</property>
    	</bean>

    3. add order as 2 to mode mapping:
    Code:
    <bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
    		<property name="order" value="2"/>
    		<property name="portletModeMap">
    			<map>
    				<entry key="view" value-ref="employeeMainController"/>
    			</map>
    		</property>
    	</bean>
    Ritesh

  10. #10

    Default

    Hi,

    Nope.. it is still not going to onsubmitAction().

    When i submit the EmployeeInfo.jsp, the request is going to browser like below.

    Code:
    http://localhost:7001/SpringPortal/SpringPortal.portal?_nfpb=true&amp;_windowLabel=SpringPortal_2&amp;_urlType=action&amp;SpringPortal_2_action=submitempinfo
    Since the submit request is going "action=submitempinfo", i feel it is again trying to show the same jsp. Thats why it is going to formbackingobject() method while displaying jsp file also while submitting it.

    Thanks,
    Lakshmi.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •