We typically validate certain data in EO, such as when the vendor is invited to register, and the Oracle standard logic verifies that the invited vendor already exists.
Its validation logic is
Oracle.apps.pos.schema.server.SupplierRegEOImpl
Public voidsetsuppliername (String value) {Supplierregentityexpert Supplierregentityexpert=Getsupplierregentityexpert (Getoadbtransaction ()); if(!supplierregentityexpert.issuppliervalid (value, Getsupplierregid ())) { Throw NewOaattrvalexception (121, Getentitydef (). Getfullname (), GetPrimaryKey (), "SupplierName", Value, "POS", "Pos_suppreg_eo _ERR1 "); } Else{setattributeinternal (2, value); return; } }
Now, because the customer feels that the standard anomaly prompt is not obvious enough, can not distinguish the supplier is a formal existence of the supplier, or has been invited by others to the supplier.
Therefore, it is decided to make logical judgments at the time of saving according to the supplier name entered.
It is verified that logical judgment cannot be written in Processformrequest, and the validation in EO is performed first.
However, it can be written in Processformdata because the method in Processformdata is executed at the post stage, so validation in EO is not triggered.
Public voidprocessformdata (oapagecontext pagecontext,oawebbean webbean) {Super. Processformdata (PageContext, Webbean); String str1= Pagecontext.getparameter ("event"); if(("Sendinvitation". Equals (str1)) | | ("Savencontinuebtnevent". Equals (STR1))) {Oaviewobject SUPPLIERREQUESTSVO= (Oaviewobject) pagecontext.getapplicationmodule ((Oawebbean) webbean.findchildrecursive ("RegSupplierRN")). Findviewobject ("Supplierrequestsvo"); String SupplierName= Pagecontext.getparameter ("SupplierName"); Number Supplierregid= (number) Supplierrequestsvo.first (). getattribute ("Supplierregid"); Logutil.of ("Validsuppliername", PageContext). Print (PageContext); Validsuppliername (Pagecontext,webbean,suppliername,supplierregid); } }
Public voidvalidsuppliername (Oapagecontext pagecontext,oawebbean webbean, String suppliername,number SupplierRegId) {LogU Til.of ("Validsuppliername Fangfa", PageContext). Print (PageContext); Oraclepreparedstatement oraclepreparedstatement=NULL; Oracleresultset Oracleresultset=NULL; Oaapplicationmodule am=Pagecontext.getapplicationmodule (Webbean); Try{oraclepreparedstatement= (oraclepreparedstatement) am.getoadbtransaction (). Createpreparedstatement ("select vendor_id \ n" + "From Po_vendors \ n" + "Where Upper (Vendo r_name) = UPPER (: 1) \ n "+ "and (Start_date_active < sysdate OR start_date_active is null) \ n" + "and (End_date_active > Sysdate OR end_da Te_active is null) \ n "+ "And rownum = 1", 1); Oraclepreparedstatement.setobject (1, SupplierName); Oracleresultset=(Oracleresultset) oraclepreparedstatement.executequery (); if(Oracleresultset.next ()) {Throw NewOaexception ("Pos_suppreg_eo_err1", Oaexception.error); } } Catch(Exception exception1) {Throwoaexception.wrapperexception (Exception1); } Try{oraclepreparedstatement= (oraclepreparedstatement) am.getoadbtransaction (). Createpreparedstatement ("Select hou.attribute18,\n" + "Papf.full_name\n" + The From P Os_supplier_registrations psr,\n "+ "Hr_all_organization_units hou,\n" + "Fnd_user fu,\n" + "Per_all_people_f papf\n "+ The WHERE Upper (PSr.supplier_name) = UPPER (: 1) \ n "+ "and psr.supplier_reg_id <>: 2\n" + "and Psr.registration_status not in (' Rejected ', \ n" + " ' DRAFT ', \ n ' + "' Rif_supplier ') \ n" + "And rownum = 1\n" + "And psr.created_by = fu.u ser_id (+) \ n "+ "And psr.ou_id = hou.organization_id\n "+ "And fu.employee_id = papf.person_id (+) \ n" + "And sysdate between NVL (papf.effective_start_date,\n" + " SYSDATE-1) and NVL (papf.effective_end_date,\n "+ "Sysdate + 1) \ n", 2); Oraclepreparedstatement.setobject (1, SupplierName); Oraclepreparedstatement.setobject (2, Supplierregid); Oracleresultset=(Oracleresultset) oraclepreparedstatement.executequery (); if(Oracleresultset.next ()) {String OrgName= oracleresultset.getstring (1); String FullName= Oracleresultset.getstring (2); Messagetoken[] Tokens= {NewMessagetoken ("Org_name", OrgName),NewMessagetoken ("Full_name", FullName)}; Oaexception Exceptionmessage=NewOaexception ("Cux", "cux_supplier_has_been_invited", Tokens,oaexception.error,NULL); ThrowExceptionmessage; PS1. Throwing an exception directly with throw causes the data for the directly EO-based field on the page to not be persisted, and validation in EO is not thrown. //pagecontext.putdialogmessage (exceptionmessage); PS2. Using Putdialogmessage (), the data on the page is retained, and the validation in the EO is performed and thrown. } } Catch(Exception exception1) {Throwoaexception.wrapperexception (Exception1); } }
Resources:
1. Re-organized Oracle OAF Learning Note--5. Implementation controller based on application construction
2.status of the Oaf-row
The standard EO validation hint error is not complete enough to throw a custom exception.