Hi,
Finally, with the help of forums, I got a simple flow to work in SWF. I am trying to implement SWF into an existing JSF/Spring app. I am trying to get the FacesContext and is null. I read the forums and keith's reply saying, that was intentional.
I did not get the annotations to work. So my config files are as follows
web-application-config.xml:
webmvc-config.xml:Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <!-- Imports the configurations of the different infrastructure systems of the application --> <import resource="webmvc-config.xml" /> <import resource="webflow-config.xml" /> </beans>
webflow-config.xml:Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <!-- Maps request URIs to controllers --> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <value> /main=flowController </value> </property> <property name="defaultHandler"> <!-- Selects view names to render based on the request URI: e.g. /main selects "main" --> <bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" /> </property> </bean> <!-- Handles requests mapped to the Spring Web Flow system --> <bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController"> <property name="flowExecutor" ref="flowExecutor"/> </bean> <!-- Maps logical view names to Facelet templates (e.g. 'search' to '/WEB-INF/search.xhtml' --> <bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.faces.mvc.JsfView"/> <property name="prefix" value="/WEB-INF/" /> <property name="suffix" value=".xhtml" /> </bean> </beans>
When I click on a button I am calling a method in StockItemsVwHandlerCode:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:webflow="http://www.springframework.org/schema/webflow-config" xmlns:faces="http://www.springframework.org/schema/faces" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <!-- Executes flows: the central entry point into the Spring Web Flow system --> <webflow:flow-executor id="flowExecutor" /> <!-- The registry of executable flow definitions --> <webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices"> <webflow:flow-location path="/WEB-INF/flows/main/main.xml" /> </webflow:flow-registry> <!-- Configures the Spring Web Flow JSF integration --> <faces:flow-builder-services id="facesFlowBuilderServices" /> <!-- Installs a listener that manages JPA persistence contexts for flows that require them --> <aop:config> <aop:advisor pointcut="execution(* com.converge.trade.persistent.services..*.*(..))" advice-ref="txAdvice" /> </aop:config> <tx:advice id="txAdvice"> <tx:attributes> <tx:method name="save*" /> <tx:method name="update*" /> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice> <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="allowCustomIsolationLevels"> <value>true</value> </property> </bean> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation"> <value>/WEB-INF/SqlMapConfig.xml</value> </property> </bean> <bean id="datawarehouse" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:jdbc/datawarehouse" /> </bean> <bean id="stockItemsService" class="com.converge.trade.persistent.model.stock.StockItemsServiceImpl"> <property name="stockItemsVwDAO"> <ref local="stockItemsVwDAO" /> </property> </bean> <bean id="stockItemsVwDAO" class="com.converge.trade.persistent.model.stock.view.stockitemsvw.StockItemsVwDAOImpl"> <property name="dataSource"> <ref local="datawarehouse" /> </property> <property name="sqlMapClient"> <ref local="sqlMapClient" /> </property> </bean> <!-- Installs a listener to apply Spring Security authorities --> </beans>
I get stockItemsService as null. Is there any other way to get the bean defined in spring?Code:public void searchRecords() { ServletContext context = FacesContext.getCurrentInstance().getExternalContext().getContext(); ApplicationContext appContext= WebApplicationContextUtils.getRequiredWebApplicationContext(context); stockItemsService = appContext.getBean("stockItemsService"); System.out.println("here asdasd'asda;" + stockItemsService); // ..... ..... ..... }
How can I get the servletContext in SWF?
Thanks
Vinaya


Reply With Quote