Announcement Announcement Module
No announcement yet.
Form submit using spring portlet Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Form submit using spring portlet

    Hi, Greetings!!

    I want to perform the following:

    I have a spring login portlet with just user id and password text fields and a submit button. Upon clicking submit button, i would like to take the entered data in text fields , pass it to back end and verify that whether the entered data exists in DB. If so, allow him to go to home page. Otherwise display a error message.

    How can i do that? Here is my html code:

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="" %>
    <%@ taglib prefix="portlet" uri="" %>
    <%@ taglib prefix="form" uri="" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    <portlet:actionURL var="aURL">
    	<portlet:param name="doThis" value="home"/>
    <html xmlns="">
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <h3>SignUp for ABC</h3>
    <form:form commandName="login" method="post" action="${aURL}">
    	<table cellpadding="4">
                        <td>ABC Id : </td>
                        <td><input type="text" size="25" maxlength="30"/></td>
                        <td>Password : </td>
                        <td><input type="text"  size="25" maxlength="30"/></td>
                        <td><input type="submit" name="_login" value="Login"  onclick="window.location.href='${aURL}';"/></td>
                        <!--<td><input type="submit" name="_cancel" value="Cancel"/></td>-->

    Here is my portlet.xml

    <?xml version='1.0' encoding='UTF-8' ?>
    <portlet-app xmlns='' xmlns:xsi='' xsi:schemaLocation='' version='2.0'>
     <!--       <portlet>   
                    <title>Sample Portal</title>
    My ABCPortlet-portlet.xml looks something like below:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xsi:schemaLocation="">
           <bean id="parameterMappingInterceptor"
                <property name="parameterName" value="doThis" />
           <bean id="portletModeParameterHandlerMapping"
              <property name="order" value="1" />
              <property name="interceptors">
                  <ref bean="parameterMappingInterceptor"/>
              <property name="portletModeParameterMap">
                  <entry key="view">
                      <entry key="login"
                      <entry key="home"
                      <entry key="regsuccess"
                  <entry key="edit">
                  <entry key="help">
           <bean id="portletModeHandlerMapping"
              <property name="order" value="2" />
              <property name="portletModeMap">
                  <entry key="view"
                  <entry key="help"
                  <entry key="edit"
           <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="prefix">
    		<property name="suffix">
    	<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    		<property name="exceptionMappings">
    				<prop key="java.lang.Exception">error</prop>
            <bean id="modeNameViewController"
    	<bean id="DataCon" class="">
    		<property name="dataSource" ref="dataSource"/>
       	<bean id="Registration" class="">
       		<property name="dataSource" ref="dataSource"/>
       		<property name="mailSender" ref="mailSender"/>
       		<property name="mailMessage" ref="mailMessage" />
    	<bean name="homeController" class="com.mosonex.portal.controller.HomePageController">
    		<property name="regService" ref="Registration"/>		
    	<bean name="regSuccessController" class="com.mosonex.portal.controller.RegistrationSuccessController">
    		<property name="regService" ref="Registration"/>		
    	<bean name="loginController" class="com.mosonex.portal.controller.LoginPageController">
    		<property name="regService" ref="Registration"/>		
            <bean name="loginController1" class="com.mosonex.portal.controller.SampleFormController">
    and the SampleFormController is as below:

    package com.mosonex.portal.controller;
    import javax.portlet.ActionRequest;
    import javax.portlet.ActionResponse;
    import org.springframework.validation.BindException;
    import org.springframework.web.portlet.mvc.SimpleFormController;
     * @author root
    public class SampleFormController extends SimpleFormController{
        protected void onSubmitAction(ActionRequest request, ActionResponse response, 
        Object command, BindException errors) throws Exception {
                        response.setRenderParameter("action", "home");
    Can somebody help me to to achieve what i mentioned in the beginning of this post.?

    IT's very urgent and i spent nearly 2 complete days on it without any success.

    ANy help in this regard is highly appreciated.


  • #2

    I have a spring login portlet with just user id and password text fields and a submit button. Upon clicking submit button, i would like to take the entered data in text fields , pass it to back end and verify that whether the entered data exists in DB. If so, allow him to go to home page. Otherwise display a error message.
    Login is something that is normally handled by your portal. It will have some way of handling authentication, which you can most likely customize. How you customize/integrate with this is a portal specific question and should be directed to the support channels for your portal.

    What problems are you encountering with your Spring portlet? What behaviour are you getting, are there any errors? Looking briefly at your code:

    1) What is com.test.ABCPortlet? You haven't posted any code for this. Is is a subclass of the Spring DispatcherPortlet?

    2) You have mixed use of the parameter name used by the portletModeParameterHandlerMapping - in your JSP and interceptor you call it "doThis", in your SimpleFormController you use "action". Furthermore, you haven't set the parameterName property on the portletModeParameterHandlerMapping so it will default to using "action".



    • #3
      Thanks for the info.

      ABCPortlet is subclass of GenericPortlet.

      I haven't declared DispatchePortlet anywhere. May be that's causing the error?

      To be honest, i'm new to spring and portlet technology. I just bought book 'SPring In Action' by manning publication and i'm doing the development.

      PLease take time to read the following and answer me whatever you think useful to me.

      We are using jetspeed as the portal server, tomcat 5.5.23 as the application server on linux Fedora 9 platform. I tried using eclipse 3.4 (ganymede) version for developing the portal. BUt even after installing plugins, when i do File -> New Project -> Other, it doesn't show up any portlet project. SO i'm stuck here.

      After little bit of search in the net, i found GlassFIsh with SUn's open portal container and net beans help to develop a portal project. It did. BUt i had trouble deploying it on the jetspeed.

      I spend almost 10 complete days in setting up the workspace with no luck.

      If somebody can help me in setting up my workspace for portal development using spring framework 2.5.5 , i will be grateful to them.

      So, pls help me to develop a spring portal project using eclipse.

      Also, as you mentioned, how can i reuse the default login page of the jetspeed portal for my portal?

      Thank you so much. All your help is highly appreciated.