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:
Code:<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="portlet" uri="http://java.sun.com/portlet" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <portlet:defineObjects/> <portlet:actionURL var="aURL"> <portlet:param name="doThis" value="home"/> </portlet:actionURL> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>MoSoNex</title> <meta name="keywords" content="" /> <meta name="description" content="" /> </head> <body> <h3>SignUp for ABC</h3> <form:form commandName="login" method="post" action="${aURL}"> <table cellpadding="4"> <tr> <td>ABC Id : </td> <td><input type="text" size="25" maxlength="30"/></td> </tr> <tr> <td>Password : </td> <td><input type="text" size="25" maxlength="30"/></td> </tr> <tr> <td><input type="submit" name="_login" value="Login" onclick="window.location.href='${aURL}';"/></td> <!--<td><input type="submit" name="_cancel" value="Cancel"/></td>--> </tr> </table> </form:form> </body> </html>
Here is my portlet.xml
My ABCPortlet-portlet.xml looks something like below:Code:<?xml version='1.0' encoding='UTF-8' ?> <portlet-app xmlns='http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd' version='2.0'> <portlet> <description>ABCPortlet</description> <portlet-name>ABCPortlet</portlet-name> <display-name>ABCPortlet</display-name> <portlet-class>com.test.ABCPortlet</portlet-class> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> <portlet-mode>EDIT</portlet-mode> <portlet-mode>HELP</portlet-mode> </supports> <portlet-info> <title>ABCPortlet</title> <short-title>ABCPortlet</short-title> </portlet-info> </portlet> <!-- <portlet> <portlet-name>dispatcher</portlet-name> <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> <portlet-mode>edit</portlet-mode> <portlet-mode>help</portlet-mode> </supports> <portlet-info> <title>Sample Portal</title> <short-title>Sample</short-title> </portlet-info> </portlet> --> <container-runtime-option> <name>javax.portlet.escapeXml</name> <value>false</value> </container-runtime-option> </portlet-app>
and the SampleFormController is as below:Code:<?xml version="1.0" encoding="UTF-8"?> <beans xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="parameterMappingInterceptor" class="org.springframework.web.portlet.handler.ParameterMappingInterceptor"> <property name="parameterName" value="doThis" /> </bean> <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="login" value-ref="loginController1"/> <entry key="home" value-ref="homeController"/> <entry key="regsuccess" value-ref="regSuccessController"/> </map> </entry> <entry key="edit"> <map/> </entry> <entry key="help"> <map/> </entry> </map> </property> </bean> <bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping"> <property name="order" value="2" /> <property name="portletModeMap"> <map> <entry key="view" value-ref="loginController"/> <entry key="help" value-ref="modeNameViewController"/> <entry key="edit" value-ref="regSuccessController"/> </map> </property> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix"> <value>/WEB-INF/jsp/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <props> <prop key="java.lang.Exception">error</prop> </props> </property> </bean> <bean id="modeNameViewController" class="org.springframework.web.portlet.mvc.PortletModeNameViewController"/> <bean id="DataCon" class="com.mosonex.portal.services.DataConImpl"> <property name="dataSource" ref="dataSource"/> </bean> <bean id="Registration" class="com.mosonex.portal.services.RegistrationImpl"> <property name="dataSource" ref="dataSource"/> <property name="mailSender" ref="mailSender"/> <property name="mailMessage" ref="mailMessage" /> </bean> <bean name="homeController" class="com.mosonex.portal.controller.HomePageController"> <property name="regService" ref="Registration"/> </bean> <bean name="regSuccessController" class="com.mosonex.portal.controller.RegistrationSuccessController"> <property name="regService" ref="Registration"/> </bean> <bean name="loginController" class="com.mosonex.portal.controller.LoginPageController"> <property name="regService" ref="Registration"/> </bean> <bean name="loginController1" class="com.mosonex.portal.controller.SampleFormController"> </bean> </beans>
Can somebody help me to to achieve what i mentioned in the beginning of this post.?Code: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{ @Override protected void onSubmitAction(ActionRequest request, ActionResponse response, Object command, BindException errors) throws Exception { response.setRenderParameter("action", "home"); } }
IT's very urgent and i spent nearly 2 complete days on it without any success.
ANy help in this regard is highly appreciated.
Regards.


Reply With Quote