Cómo habilitar / deshabilitar el elemento en selecManyCheckbox basado en la bandera
Necesito su ayuda para deshabilitar y habilitar un elemento delselectManyCheckbox
componente en una página jsf. En primer lugar, el componente selectManyCheckbox muestra tres chechboxes que son (Préstamo - Salud - Transferencia). La lista se completará a partir de un bean que tiene el código:
private List<hrCertificate> hrCertificatesList = new ArrayList<hrCertificate>();
//Getter and Setter
Private String loanFlag="";
@PostConstruct
public void init() {
this.hrCertificatesList.add(new hrCertificate(("Loan"), "LC"));
this.hrCertificatesList.add(new hrCertificate(("Health"), "HI"));
this.hrCertificatesList.add(new hrCertificate(("Trasnfer"), "TE"));
}
En el mismo bean, ejecutaré una instrucción SQL que devolverá Sí o No y ese valor lo estoy agregando alloanFlag
variable. Por lo tanto, si la bandera = "Y", necesito habilitar la casilla de verificación de préstamo para que el usuario pueda seleccionarla, de lo contrario, debo deshabilitarlaselectManyCheckbox
. El problema es que tengo dificultades para aplicar la lógica para deshabilitar y habilitar el elementoselectManyCheckbox
donde en el código anterior estoy enumerando y habilitándolos todo el tiempo.
El código para selectManyChexkbox:
<p:selectManyCheckbox id="hrCertificates" value="#{user.selectedHRCertificates}" layout="pageDirectio>
<f:selectItems value="#{user.hrCertificatesList}"
var="hrCertificate" itemLabel="#{hrCertificate.hrCertificateName}"
itemValue="#{hrCertificate.hrCertificateCode}"/>
</p:selectManyCheckbox>
Entonces, ¿cómo aplicar la lógica?