2012-02-06 58 views
0

我需要向用户确认他或她是否确定要删除他或她的帐户。 为此,我认为弹出屏幕会很酷。但大多数浏览器阻止弹出窗口。如何在富文件中调用托管bean操作:popupPanel

所以我试图用popupPanel做到这一点。 但我猜这不会是可能的,因为我有它内部的commandLink,这里就是我doind至今:

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

}

任何想法如何做到这一点?

+0

那么,什么是你的问题是什么呢?为什么你想通过单击Yes链接使用户的会话失效? – Nikhil 2012-02-10 11:26:08

回答

0

有两个样品供您问题RichFaces的演示

住在RF 4现场演示,它们包括托管bean的样本。

希望它有帮助。

+0

OP已经发布了一个链接到RF4展示自己:) – BalusC 2012-02-06 17:17:00

+0

@BalusC是我注意到,但我发布的示例是一个使用popupPanel编辑/删除数据的dataTable,类似于他的问题。 – 2012-02-06 17:26:12

+0

对啊,对不起,你在解释具体问题和解决方案时并不清楚。 – BalusC 2012-02-06 17:33:24

0

富如何调用托管bean行动: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>