1

現在、Post/Redirect/Get パターンにより、すべてのフロー URL は似たようなもの<site_url>/flow_name?execution=?であり、入力 GET パラメータは保持されません。したがって、ユーザーは URL をコピーしたり、ブックマークしたりすることはできません。

これをきちんと行うにはどうすればよいですか?

4

2 に答える 2

1

SWF API のFlowHandlerAdapterをカスタマイズすることで、SWF ベースのアプリケーションの URL をブックマークできます。

以下にサンプルを示します。

私の SWF 設定ファイルは次のようになります。

<bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
      <property name="flowHandlerAdapter" ref="customFlowHandlerAdapter" /> 
     </bean>

     <bean id="customFlowHandlerAdapter" class="com.xyz.CustomFlowHandlerAdapter">
        <property name="flowExecutor" ref="flowExecutor" /> 
        <property name="flowUrlHandler" >
            <bean class="com.xyz.CustomURLFlowHandler" /> 
        </property>
     </bean>

私の CustomFlowHandlerAdapter は次のようになります。

public class CustomFlowHandlerAdapter extends FlowHandlerAdapter {

...

@Override
    public ModelAndView handle(HttpServletRequest request,
            HttpServletResponse response, Object handler) throws Exception {
        FlowHandler flowHandler = (FlowHandler) handler;
        checkAndPrepare(request, response, false);
        String flowExecutionKey = this.getFlowUrlHandler()
                .getFlowExecutionKey(request);
        if (flowExecutionKey != null)
            try {
                ServletExternalContext context = createServletExternalContext(
                        request, response);
                FlowExecutionResult result = this.getFlowExecutor().resumeExecution(
                        flowExecutionKey, context);
                handleFlowExecutionResult(result, context, request, response,
                        flowHandler);
            } catch(org.springframework.webflow.execution.repository.NoSuchFlowExecutionException ex){
                response.sendRedirect(request.getRequestURI());
            } catch(org.springframework.webflow.execution.repository.BadlyFormattedFlowExecutionKeyException ex){
                response.sendRedirect(request.getRequestURI());
            } catch (FlowException e) {
                handleFlowException(e, request, response, flowHandler);
            }
....

ここでは、NoSuchFlowExecutionException をキャッチし、パラメーターなしで正確なフロー URL にリダイレクトしています。ここで、パラメータを取得して再含めることができます

したがって、任意の状態から URL をブックマークすることができます (フローは常に最初から開始されます)。また、必要に応じて独自のパラメーターを送信することもできます。

于 2013-10-16T12:11:38.490 に答える
0

フローの開始点の 1 つへのリンクをいつでも使用してブックマークすることができます。
たとえば<site_url>/flow_name?personId=123&projectId=456、フローpersonIdとに 2 つの入力があると仮定して実行できますprojectId。ただし、URL を知る必要があります (ユーザーに提供する必要があります)。アドレス バーの URL を使用することはできません。

そうしたいとしても、フロー内の特定の状態へのリンクを使用してブックマークすることはできません (値に応じて特定のイベントに誘導するロジックをフローの開始に追加しない限り)。入力の)。

于 2012-11-29T16:00:05.023 に答える