I want to check the following: I have a dataTable, but selected a row and I click the edit button, then you must leave a message, otherwise open a popup so that the user can change the value
my button is:
<p:commandButton value="#{bundle.Edit}" id="editBotonFormula" icon="ui-icon-pencil" update=":growl" oncomplete="handleSubmit(args,'OprEditarFormulaDialog');" actionListener="#{oprFormulaMedicaController.validarSeleccionado}"/>
My Managed bean method is:
public void validarSeleccionado(){
if (selected != null) {
System.out.println(" hay dato seleeccionado en formulaMedica" + selected);
//open popup to edit Dialogvar.Show;
}
else {
System.out.println("No hay dato seleccionado " + selected);
//Show open error message (growl) and not open popup JsfUtil.addErrorMessage(ResourceBundle.getBundle("/Bundle").getString("NoHayFilaSeleccionada"));
}
}
My question is : How can I open the dialog (popup)if the row is selected ?????
thanks
Try the following
if (selected != null) {
System.out.println(" hay dato seleeccionado en formulaMedica" + selected);
RequestContext context = RequestContext.getCurrentInstance();
context.execute("PF('OprEditarFormulaDialog').show();");
}
by using the Primefaces function PF
to locate your dialog. Prerequisite: You have a p:dialog
with widgetvar="OprEditarFormulaDialog"
.