Case
Any new Department must provide at least one Employee.
Implementation Method
return true;
return false;
public void validateBindingContainer(BindingContainer bindingContainer) {
if( ( (DCIteratorBinding) bindingContainer.get("DETAIL_ITERATOR_NAME")).getCurrentRow()==null){
throw new ValidatorException(new FacesMessage("Create a new Contact info before commit"));
}
}
then go to page definition properties and set two properties
CustomValidator="#{YOUR_CUSTOM_VALIDATE_MANAGED_BEAN}"
SkipValidation="custom"
Any new Department must provide at least one Employee.
Implementation Method
- Create "Business Component from Tables" for Departments and Employees.
- Check the property "Composition Association" at the association.
- Using "Entity Validators" of type "Script Expression"
Create new "Validator" on the Department of type script Expression and write:
return true;
return false;
- Using "Entity Validators" of type"Collection":
Cretae new entity validators on Department of type "Collection",
Choose the :
Operation = "Count"
Accessor = Accessor Name of Employee.
Atribute = any attribute
Operator = "GreaterOrEqualTo"
Enter Literal Value = 1 - Create managed been class implements "BindingContainerValidator" interface and overrides "validateBindingContainer" method:
public void validateBindingContainer(BindingContainer bindingContainer) {
if( ( (DCIteratorBinding) bindingContainer.get("DETAIL_ITERATOR_NAME")).getCurrentRow()==null){
throw new ValidatorException(new FacesMessage("Create a new Contact info before commit"));
}
}
then go to page definition properties and set two properties
CustomValidator="#{YOUR_CUSTOM_VALIDATE_MANAGED_BEAN}"
SkipValidation="custom"
No comments:
Post a Comment