Question

In the implementation of oracle forms "when-validate-item" trigger in ADF The sample code is as shown below.

declare
sysdate1 date;
begin
begin 
select sysdate into sysdate1 from dual; 
if to_char(:xdate,'cc') < '20' then 
message('Verify the Century Please'); 
message('Verify the Century Please', NO_ACKNOWLEDGE); 
raise form_trigger_failure; 
end if; 
if x_date > sysdate1 then 
message('You cannot enter future date'); 
message('You cannot enter future date', NO_ACKNOWLEDGE); 
raise form_trigger_failure; 
end if; 
dp_date();
end;

Is this possible to programmatically change the validator message in entity object? because i am implementing oracle forms "When-validate-Item-trigger" ,where based on a condition the error message is changed as above.[ in ADF we can create more than one message] i refer to this statement "The Script Expression validator allows you to enter more than one error message. This is useful if the validation script conditionally returns different error or warning messages" at this link http://docs.oracle.com/cd/E23943_01/web.1111/b31974/bcvalidation.htm#CACCGAJH but did not provide any example, could any body provide me any "pointer" or any other way of implementing this? Thanks in Advance.

Was it helpful?

Solution

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.enter image description here

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top