weixin_39918128 2020-11-20 13:09
浏览 1

Control(ComboBox) stuck with Mandatory flag

Original report by Hadi Fakhreddin (Bitbucket: hadifa, GitHub: hadifa).

Changing a control as not required after it being rendered as required does not remove the "mandatory" flag e.g. ValidationSupport.setRequired(doctors, false);

Interestingly it doesn't take effect once it's rendered!


#!java

private ValidationSupport validationSupport = new ValidationSupport();
 private ComboBox<practitioner> practitioners; 
 private CheckBox allPractitioners;

public IncomeAccountingNode(){ 
validationSupport.registerValidator(practitioners, true, Validator.createEmptyValidator("Practitioner(s) is required"));  

// ValidationSupport.setRequired(practitioners, false); // this takes effect if uncommented

allPractitioners.setOnAction((ActionEvent ae) -> {
    if (allPractitioners.isSelected()) {
        ValidationSupport.setRequired(practitioners, false);  //is not removing the mandatory flag
    } else {
        ValidationSupport.setRequired(practitioners, true);
    }
});
}
</practitioner>

该提问来源于开源项目:controlsfx/controlsfx

  • 写回答

6条回答 默认 最新

  • weixin_39918128 2020-11-20 13:09
    关注

    Original comment by Eugene Ryzhikov (Bitbucket: eryzhikov, GitHub: Unknown).

    Looks like it was fixed a while ago, I just could not confirm the fix. HelloValidation sample now has a button to toggle the required state of the text field in the sample.

    评论

报告相同问题?