I am trying enable/disable a commandLink depending on a boolean flag. When a commandButton is clicked, I am trying to fix the boolean flag to false, and use the "disable" property of commanLink to fix disable=false
commandLink is disabled onstart:
<div align="right" style="display: block; float: right;">
<p:commandLink id="buttonGuardar" action="#{vinculacionesGestionDetalleController.buttonGuardar}" update="@form" process="@form" styleClass="fa-commandlink fa-floppy-o" inmediate="true" disabled="#{vinculacionesGestionDetalleController.flagGuardar}">
<h:outputText value="#{msg.guardar}" />
</p:commandLink>
</div>
When this commandButton is clicked, I want to change the value of the boolean flag:
<p:commandButton id="validacionesValidarCodigoButton" actionListener="#{vinculacionesGestionDetalleController.buttonValidar}" value="Validar" styleClass="searchButton" icon="fa fa-button fa-check-circle" process="@form" style="margin-left: 20px;">
</p:commandButton>
Controller:
private boolean flagGuardar = true;
public void buttonValidar(ActionEvent event) {
Boolean validacion = false;
validacion = vinculacionesService.validarCodigo(vinculacionLaboral.getCodigo());
if (validacion == true) {
super.addMessageInfo("listas_gestion_info_titulo",
"vinculaciones_gestion_detalle_validacion_success");
flagValidacion = true;
//setFlagGuardar(false);
flagGuardar = false;
} else {
super.addMessageError("listas_gestion_info_titulo",
"vinculaciones_gestion_detalle_validacion_unsuccess");
flagValidacion = false;
//setFlagGuardar(true);
flagGuardar = true;
}
//return flagValidacion;
}
What I am doing wrong?
Thank you.
update="@form"to the button? - Gimby