2012-02-06 18 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> 
相關問題