|
|
Problem in implementing Spring webflow 2
Hi All,
Need Help!! as I am totally new to Spring mvc+webflow.
Presently I need to develop a project by using Spring webflow which has a login page and once we click on submit button it should display a new page which has Menu item list in the form of hyperlinks. If we click on any hyperlink it will open a form. My problem is I am not able to find solution to display Login page and then menu item page. Presently what I have done is:
1. I have made a simple login page with submit button in jsp
2. Made a Menu page
3. Created a web.xml
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;web-app xmlns=quot;xml/ns/javaeequot; xmlns:xsi=quot;2001/XMLSchema-instancequot; xsi:schemaLocation=quot;xml/ns/javaee xml/ns/javaee/web-app_2_5.xsdquot; version=quot;2.5quot;gt; lt;!-- Spring MVC front controller. Automatically loads mycart-servlet.xml based on servlet name. --gt; lt;servletgt; lt;servlet-namegt;aaalt;/servlet-namegt; lt;servlet-classgt;org..web.servlet.DispatcherSe rvletlt;/servlet-classgt; lt;init-paramgt; lt;param-namegt;contextConfigLocationlt;/param-namegt;lt;param-valuegt; /WEB-INF/aaa-servlet-config.xml /WEB-INF/aaa-webflow-config.xmllt;/param-valuegt; lt;/init-paramgt; lt;load-on-startupgt;1lt;/load-on-startupgt; lt;/servletgt;
lt;welcome-file-listgt; lt;welcome-filegt;index.jsplt;/welcome-filegt; lt;/welcome-file-listgt; lt;servlet-mappinggt; lt;servlet-namegt;aaalt;/servlet-namegt; lt;ucl-patterngt;*.dolt;/ucl-patterngt; lt;/servlet-mappinggt;
lt;/web-appgt;
4. Created aaa-servlet-config.xml
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;beans xmlns=quot;schema/beansquot; xmlns:aop=quot;schema/aopquot; xmlns:context=quot;schema/contextquot; xmlns:flow=quot;schema/webflow-configquot; xmlns:util=quot;schema/utilquot; xmlns:xsi=quot;2001/XMLSchema-instancequot; xsi:schemaLocation=quot;schema/beans schem...-beans-2.5.xsd schema/aop schem...ng-aop-2.5.xsd schema/context schem...ontext-2.5.xsd schema/webflow-config schem...config-2.0.xsd schema/util schema/util/spring-util-2.0.xsdquot;gt; lt;!-- lt;bean id=quot;loginControllerquot; class=quot;com.anfcorp.action.LoginControllerquot;/gt; --gt;
lt;bean name=quot;/Login.doquot; class=quot;org..webflow.mvc.servlet.Flo wControllerquot;gt; lt;property name=quot;flowExecutorquot; ref=quot;flowExecutorquot; /gt; lt;property name=quot;flowuclHandlerquot;gt;lt;bean class=quot;org..webflow.context.servlet .WebFlow1FlowuclHandlerquot; /gt; lt;/propertygt; lt;/beangt;
lt;!-- Maps flow view-state view names to JSP templates --gt; lt;bean id=quot;viewResolverquot; class=quot;org..web.servlet.view.Intern alResourceViewResolverquot;gt; lt;property name=quot;prefixquot; value=quot;/pages/quot; /gt; lt;property name=quot;suffixquot; value=quot;.jspquot; /gt; lt;/beangt;
lt;/beansgt;
5. Created aaa-webflow-config.xml
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;beans xmlns=quot;schema/beansquot; xmlns:aop=quot;schema/aopquot; xmlns:context=quot;schema/contextquot; xmlns:flow=quot;schema/webflow-configquot; xmlns:util=quot;schema/utilquot; xmlns:xsi=quot;2001/XMLSchema-instancequot; xsi:schemaLocation=quot;schema/beans schem...-beans-2.5.xsd schema/aop schem...ng-aop-2.5.xsd schema/context schem...ontext-2.5.xsd schema/webflow-config schem...config-2.0.xsd schema/util schema/util/spring-util-2.0.xsdquot;gt; lt;flow:flow-executor id=quot;flowExecutorquot; flow-registry=quot;flowRegistryquot;gt; lt;/flow:flow-executorgt; lt;flow:flow-registry id=quot;flowRegistryquot;gt;lt;flow:flow-location path=quot;/WEB-INF/flows/login.xmlquot; /gt; lt;/flow:flow-registrygt;
lt;/beansgt;
6. Created Login.xml
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;flow xmlns=quot;schema/webflowquot;
xmlns:xsi=quot;2001/XMLSchema-instancequot;
xsi:schemaLocation=quot;schema/webflow
schema/webflow/spring-webflow-2.0.xsdquot;gt;
lt;!-- New customers create a new account before moving forward --gt;
lt;view-state id=quot;loginquot; view=quot;Loginquot;gt;
lt;transition on=quot;submitquot; to=quot;loginOkquot;/gt;
lt;/view-stategt;
lt;!-- See showthread.php?t=51240 --gt;
lt;!-- Suppress leading slash to go servlet-relative? (Check docs) --gt;
lt;!-- View applies only when directly called; calling flows ignore it? --gt;
lt;end-state id=quot;loginOkquot; view=quot;AAAHome.doquot;/gt;
lt;/flowgt;
7. I have made a very general Controller class for Login page. Not sure whether it is correct or not.
package com.anfcorp.action;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.from.fromServletRequest;
import javax.servlet.from.fromServletResponse;
import org..stereotype.Controller;
import org..ui.ModelMap;
import org..web.bind.annotation.RequestMap ping;
import org..web.bind.annotation.RequestMet hod;
import org..web.servlet.ModelAndView;
import org..web.servlet.view.RedirectView;
import org..web.servlet.mvc.SimpleFormCont roller;
@Controller
public class LoginController {//extends SimpleFormController{
public LoginController() { System.out.println(quot;inside Logincontroller constructor....quot;); } @RequestMapping(quot;/Login.doquot;) public void doLogin() { System.out.println(quot;inside doHome method.....quot;);
}
}
8. After all this on the browser I passed: AAA-rewrite/Login.do. It is giving exception: java.lang.IllegalArgumentException: An id is required to lookup a FlowDefinition
I need all your help to display login page and menu item page. If you can provide any example similar to this it will be a great help. |
|