1

JSFを純粋なフロントエンドツールとして使用しようとしています。フォームを送信し、そのフォームの結果に基づいて別のページにリダイレクトすることはできますか?この場合、結果変数で結果を返すバックエンドサービスがあります。「result.success」に応じて、適切なページ/ビューに移動したいと思います。これが私のJSFソースコードです:

<!DOCTYPE html>
 <html lang="en"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:r="http://mycustomtags.com/tags"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:c="http://java.sun.com/jsf/core">
  <head>
    <r:myService service="adminlogin" namespace="result" params='{"dummy":"Dummy Value"}' />
  </head>
  <body>
    #{result}
    <f:viewParam name="redirectPage" value='#{(result.success)?"success.xhtml?faces-redirect=true" : "sample-login.xhtml?IncludeViewParams=true"}' />
    output:#{redirectPage}
    <h:form method="post" action="sample-login.xhtml">
        <input name="token" type="hidden" class="input-block-level" value="34857349850" />
        <input name="email" type="text" class="input-block-level" placeholder="email" />
        <input name="password" type="password" class="input-block-level" placeholder="password" />
        <h:commandButton action="#{redirectPage}" value="Login" />
    </h:form>           
  </body>
</html>

success.xhtmlに移動する必要があります。「faces-config.xml」は使いたくない。何か案は?これが私のJSFコードです。ちなみに、「h:commandButton」のアクションパラメータはMethodExpressionを想定しているため、これは機能しません。

4

0 に答える 0