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 ?
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>
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.