jsf 2 - How to display a confirmation dialog(Primefaces) from backing bean -


i have import function parse xml file contains version information of document , save in database. if user try upload existing version, need show confirmation dialog " version exists wants overwrite..?" ok, cancel.

i using mozarra 2.0.3, prime faces 2.2 rc2, glass fish 3 , trying way.

<h:form id="condialog">     <p:commandbutton value="getconfirmmsg" update="condialog" action="#{buttonbean.getconfirmmsg()}"          oncomplete="confirmation.show()"/>     <p:growl id="messages1" globalonly="true"/>     <p:confirmdialog message="version exists. want override it?"         rendered="#{buttonbean.showconfirm}"         header="version exist" severity="alert" widgetvar="confirmation">         <p:commandbutton value="ok" update="messages1" oncomplete="confirmation.hide()"             action="#{buttonbean.overrideversion}" />         <p:commandbutton value="cancel" onclick="confirmation.hide()" type="button" />     </p:confirmdialog> </h:form> 

backingbean

@managedbean @requestscoped public class buttonbean {      boolean showconfirm = false;      public boolean isshowconfirm() {         return showconfirm;     }      public void setshowconfirm(boolean showconfirm) {         this.showconfirm = showconfirm;     }      public void overrideversion() {         system.out.println("version alrady exists...overriding...");         facesmessage msg = new facesmessage("action successful");         facescontext.getcurrentinstance().addmessage(null, msg);     }      public void getconfirmmsg() {         system.out.println("inside getconfirmmsg()....");         showconfirm = true;         system.out.println("showconfirm: " + showconfirm);     } } 

when click on "ok" action not firing. there mistake in above code?

it's not possible confirmation client during processing on server.

you have 2 options:

  1. get overwrite permission before calling action method e.g. checkbox "overwrite file if exists?" or

  2. you have stop processing, set flag , return null reload current page in browser. display p:dialog depending on flag status.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -