使用布尔标志和ActionListener启用/禁用commandLink。 JSF PrimeFaces

时间:2017-01-10 12:04:33

标签: java jsf primefaces

我正在尝试根据布尔标志启用/禁用commandLink。当单击commandButton时,我试图将布尔标志修复为false,并使用"禁用" commanLink的属性来修复disable = false

在开始时禁用了commandLink:

<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>

单击 commandButton 时,我想更改布尔标志的值:

<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>

控制器:

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;
}

我做错了什么?

谢谢。

1 个答案:

答案 0 :(得分:0)

试试这个

   <p:commandButton id="validacionesValidarCodigoButton" actionListener="#{vinculacionesGestionDetalleController.buttonValidar}" value="Validar" styleClass="searchButton" icon="fa fa-button fa-check-circle" update="buttonGuardar" style="margin-left: 20px;">
    </p:commandButton>