Spring webflow + portal - How do you get url parameters in the flow definition?
I am kinda new to the portals and spring webflow and trying to combine them for the purpose of setting flows for various user tasks. My problem is that I need to generate a direct URL to the first state and pass in the name of the subflow as a parameter so the right subflow is executed from there onwards - I don't know how to get that parameter.
Here is my context config
<!-- Maps portlet modes to handlers -->
<bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
<property name="portletModeMap">
<map>
<entry key="view">
<bean class="com.mycompany.login.portlet.ViewFlowHandler" />
</entry>
</map>
</property>
</bean>
<!-- Enables FlowHandlers -->
<bean class="org.springframework.webflow.mvc.portlet.FlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor"/>
</bean>
<!-- Executes flows: the central entry point into the Spring Web Flow system -->
<webflow:flow-executor id="flowExecutor">
</webflow:flow-executor>
<!-- The registry of开发者_开发技巧 executable flow definitions -->
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderService">
<webflow:flow-location path="classpath:flows/login-flow.xml" />
<webflow:flow-location path="classpath:flows/main-flow.xml" />
<webflow:flow-location path="classpath:flows/pwd-recovery-flow.xml" />
</webflow:flow-registry>
<webflow:flow-builder-services id="flowBuilderService" view-factory-creator="viewFactoryCreator"/>
<bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="viewResolvers">
<list>
<ref bean="viewResolver"/>
</list>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/flow-views/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!-- beans for business logic -->
<bean id="authService"
class="com.mycompany.login.portlet.service.AuthService"
scope="prototype" />
<!-- constants -->
<bean id="flowNames" class="com.mycompany.login.portlet.Flows" scope="singleton">
<property name="loginMain"><value></value></property>
<property name="passwordRecover"><value>pwd-recovery</value></property>
<property name="finish"><value>finish</value></property>
<property name="nflow"><value></value></property>
</bean>
My flow handler:
package com.mycompany.login.portlet;
import javax.servlet.http.HttpServletRequest;
import org.springframework.webflow.core.collection.LocalAttributeMap;
import org.springframework.webflow.core.collection.MutableAttributeMap;
import org.springframework.webflow.mvc.portlet.AbstractFlowHandler;
public class ViewFlowHandler extends AbstractFlowHandler{
public String getFlowId() {
return "main-flow";
}
}
And the point of entry is the main-flow which based on the get parameter in the url called "flo" will redirect to a sub-flow. Currently when I try to access this directly, my requestParameter map is blank. I don't know what the url would be in this case. An example of the current URL is "http://localhost:8080/portal/portal/default/Login/Mycompany+LoginWindow?flo=pwd-recovery". Also later on I want to pass in additional parameters in the URL such as userid etc. but I'm getting a blank map for requestParameters right now. Here is my entry point flow definition
main-flow.xml
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<action-state id="branch">
<on-entry>
<!-- <evaluate expression="flowNames.setNflow(requestParameters.flo)"/> -->
<evaluate expression="flowNames.checking(requestParameters)"/>
</on-entry>
<evaluate expression="flowNames.enableTransition()" />
<transition on="yes" to="proceed" />
</action-state>
<action-state id="proceed">
<!--<if test="flowNames.nflow==''" then="login"/>
<if test="flowNames.nflow=='pwd-recovery'" then="pwd-recovery"/>
<if test="flowNames.nflow=='finish'" then="finish-main"/>-->
<on-entry>
<!-- <evaluate expression="flowNames.setNflow(requestParameters.flo)"/> -->
<evaluate expression="flowNames.checking(requestParameters)"/>
</on-entry>
<evaluate expression="flowNames.nflow"/>
<transition on="pwd-recovery" to="pwd-recovery"/>
<transition on="finish" to="finish-main"/>
<transition to="login"/>
</action-state>
<subflow-state id="login" subflow="login-flow">
<transition on="finish-login" to="proceed"/>
</subflow-state>
<subflow-state id="pwd-recovery" subflow="pwd-recovery-flow">
<transition on="finish-pwd" to="proceed"/>
</subflow-state>
<end-state id="finish-main"/>
I think your issue is not to do with Spring Webflow so much as portlets. Check out:
http://wpcertification.blogspot.com/2010/05/getting-query-string-of-portal-url-from.html
Which shows one way to get request parameters from a portlet. However I don't know how to do this from within Spring webflow - though I'm trying to find out!!!
精彩评论