Spring webflow + Portal - 如何获取流定义中的 url 参数?

发布于 2024-10-10 08:25:10 字数 5021 浏览 8 评论 0原文

我对门户网站和 spring webflow 有点陌生,并尝试将它们组合起来以便为各种用户任务设置流程。我的问题是,我需要生成第一个状态的直接 URL,并将子流的名称作为参数传递,以便从那里开始执行正确的子流 - 我不知道如何获取该参数。

这是我的上下文配置

<!-- 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>

我的流处理程序:

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";
    }

}

入口点是主流,它基于名为“flo”的 url 中的 get 参数将重定向到子流。目前,当我尝试直接访问它时,我的 requestParameter 映射是空白的。我不知道在这种情况下网址是什么。当前 URL 的示例是“http://localhost:8080/portal/portal/default/Login/Mycompany+LoginWindow?flo=pwd-recovery”。另外,稍后我想在 URL 中传递其他参数,例如 userid 等,但我现在得到 requestParameters 的空白映射。这是我的入口点流定义

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 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"/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅笑轻吟梦一曲 2024-10-17 08:25:10

我认为您的问题与 Spring Webflow 无关,而与 portlet 有关。查看:

http://wpcertification。 blogspot.com/2010/05/getting-query-string-of-portal-url-from.html

其中显示了从 portlet 获取请求参数的一种方法。然而我不知道如何从 Spring webflow 中做到这一点 - 尽管我正在努力找出答案!

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!!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文