簡體   English   中英

如何在rich:popupPanel中調用托管bean動作

[英]How to invoke managed bean action in rich:popupPanel

我需要與用戶確認他或她是否確定要刪除其帳戶。 為此,我認為彈出屏幕會很酷。 但是大多數瀏覽器都會阻止彈出窗口。

所以我試圖用popupPanel做到這一點 但是我猜想那不可能,因為我里面有一個commandLink,這就是我到目前為止所要做的:

<rich:popupPanel id="popup_delete_profile" modal="true" onmaskclick="#{rich:component('popup_delete_profile')}.hide()">
        <f:facet name="header">
            <h:outputText value="Aviso" />
        </f:facet>

        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('popup_delete_profile')}.hide(); return false;">
            Close
            </h:outputLink>
        </f:facet>


        <p>Are you sure ?</p>

        <h:commandLink value="Yes" action="#{userc.deleteUser}"></h:commandLink>

        <h:outputLink value="#" onclick="#{rich:component('popup_delete_profile')}.hide(); return false;">
            No
        </h:outputLink>        

    </rich:popupPanel>

這是我的manageBean:

    public void deleteUser(){
        try {
                eaoUser.delete(userb.getUser());
                // here I would like to refresh the popupPanel saying that was deleted with success and then logout

        } catch (Exception e) {
            view.errorMessage("ocorreu um erro, por favor tente novamente");
            e.printStackTrace();
        }
    }

編輯:

public String deleteUser() {
        FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
        return "/index.xhtml?faces-redirect=true";

}

知道怎么做嗎?

如何在rich:popupPanel中調用托管bean動作

   Add this code in your popUp.xhtml page

    Note:replace rich:popuppanal and use rich:modalPanel

    <a4j:commandLink styleClass="no-decor" execute="@this" render="@none"
        oncomplete="#{rich:component('confirmPane')}.show()">
        <h:graphicImage value="/images/icon-delete.gif" />
        </a4j:commandLink>

        <rich:modalPanel id="confirmPane" width="282" height="70">
        Are you sure you want to delete the row?
        <button id="cancel"  onclick="#{rich:component('confirmPane')}.hide();" >
        <h:outputText value="cancel" escape="false" />
        </button>
        <button id="delete"  onclick="#{rich:component('confirmPane')}.hide();                  clickHiddenButton('officeForm:yesSubmit');return true;">
        <h:outputText value="yes" escape="false" />
        </button>
        <h:commandButton id="yesSubmit" style="visibility:hidden;"
        onclick="#{rich:component('confirmPane')}.hide()" action="deleteRecord" />
        </rich:modalPanel>

richFaces現場演示中有兩個樣本可以解決您的問題

在RF 4現場演示中,它們包括受管Bean的示例。

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM