In The above scenario we can solve the problem using two ways(as per my knowledge). if we are having items from other entity objects(other than present EO in which this item is available) in the code, Then we can write a "when-validate-item" trigger method in managed bean and we can call it in the blur event of that item.
The secound one is interesting, create a Expression validator in the business rule of the item in entity object, select "script expression" as rule type and give "rule definition" as "source.customValidateItem(newValue)" where "customValidateItem" is your custom method in your EntityImpl class, and were are calling it using groovy expression, and set the Failure handling message as shown in below diagram.
Before this you need to create an transient variable like ex:message and we can access the value of that item(message) from EntityImpl class using groovy expression "source.message" and setting the "message" item value in the same class based on if conditions like above code Ex:if(gid!=223) {
setmessage("Please check gid is not 223!!");
return false;
}else if(gid!=224){
setmessage("please check gid is not 224!!");
return false;
}
setmessage is the accessor created in EntityImpl.
hope this helps to some body
Thanks.