0

I have a faces-config.xml that contains a lot of navigation rules but I'm not able to get a redirect-param in my page.

I've searched a lot about this issue but I couldn't find any helping response.

detail.xhtml:

<p:commandLink action="#{bean.delete()}">
    <f:setPropertyActionListener target="#{bean.deletionSuccess}" value="true" />
    <p:confirm header="Confirmation" message="Are you sure?"
</p:commandLink>

faces-config.xml:

<navigation-rule>
    <from-view-id>/myDetailPage.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>deletionSuccess</from-outcome>
        <to-view-id>/myOverviewPage.xhtml</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>

Java-Bean:

   private String deletionSuccess;

    public String delete() {
        // do something
        return "deletionSuccess";
    }
    public void setDeletionSuccess(String deletionSuccess) { this.deletionSuccess = deletionSuccess; }

    public String getDeletionSuccess() { return deletionSuccess; }

overview.xhtml:

<f:metadata>
    <f:viewParam name="deletionSuccess" value="#{bean.deletionSuccess}"/>
    <f:viewAction action="#{bean.init}"/>
</f:metadata>
...
<h:form id="mainform" class="form-horizontal overview" role="form" method="post">
    <h:panelGroup styleClass="row" rendered="#{!empty housePlantBean.deletionSuccess}">
...

What am I doing wrong? Or how can I get the redirect-param in my XHTML-page?

Thanks a lot for your help!

4

1 に答える 1

1

これはそのような方法では機能しません。

まず、facelet で定義する必要があります。たとえば、<f:viewParam>次のようになります。myOverviewPage.xhtml

<f:metadata>
    <f:viewParam name="deletionSuccess" value="#{bean.deletionSuccess}"/>
</f:metadata>

定義していたと思います。


パラメータを渡す簡単な方法は、use<h:button>または<h:link>on myDetailPage.xhtmlfacelet です。

<h:button outcome="deletionSuccess">
    <f:param name="deletionSuccess" value="#{true}"/>
</h:button>

public String delete()しかし、メソッドの呼び出しはありません。

したがって、このメソッドのリダイレクトと呼び出しが必要な場合は、<h:commandButton>orを使用する必要があります。次に<h:commandLink>例を示します。

<h:commandButton value="submit" action="#{bean.delete}">
    <f:setPropertyActionListener target="#{bean.deletionSuccess}" value="#{true}" />
</h:commandButton>

--- 更新
ナビゲーション ルールに正しいファイル名を保持してください

<navigation-rule>
    <from-view-id>/detail.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>deletionSuccess</from-outcome>
        <to-view-id>/overview.xhtml</to-view-id>
        <redirect include-view-params="true"/>
    </navigation-case>
</navigation-rule>

に追加してくださいdetail.xhtml

<p:confirmDialog global="true" showEffect="fade" >
   <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
   <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
</p:confirmDialog>

またはタグ<p:confirm header="Confirmation" message="Are you sure?"/> から削除 <p:commandLink>

于 2014-04-25T16:40:27.173 に答える