如何在 rich:popupPanel 中调用托管 bean 操作

发布于 2025-01-02 18:30:42 字数 2164 浏览 3 评论 0原文

我需要与用户确认他或她是否确定要删除他或她的帐户。 为此,我认为弹出屏幕会很酷。但大多数浏览器都会阻止弹出窗口。

所以我试图用 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";

}

知道如何做到这一点吗?

I need to confirm with the user if he or she are sure about delete his or her account.
For this I think a popup screen would be cool. But most browser block the popup windows.

So I was trying to do that with popupPanel.
But I'm guessing that would not be possible because I have a commandLink inside of it, here's what I'm doind so far :

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

This is my 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();
        }
    }

EDIT:

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

}

Any idea how to do that ?

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

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

发布评论

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

评论(2

抱着落日 2025-01-09 18:30:42

richFaces 实时演示中有两个示例可解决您的问题

在 RF 中4 个现场演示,它们包括托管 Bean 的示例。

希望有帮助。

There are two samples for your problem in the richFaces live demo

In the RF 4 live demo, they include a sample of the Managed Bean.

Hope it helps.

清晨说晚安 2025-01-09 18:30:42

如何在 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>

How to invoke managed bean action in rich:popupPanel

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