Implement Method Validation

Advanced Oracle ADF 12c Course Model|Method Validation
18 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€67.24
List Price:  €96.07
You save:  €28.82
£55.68
List Price:  £79.55
You save:  £23.86
CA$100.66
List Price:  CA$143.82
You save:  CA$43.15
A$111.82
List Price:  A$159.75
You save:  A$47.93
S$94.88
List Price:  S$135.55
You save:  S$40.66
HK$543.79
List Price:  HK$776.87
You save:  HK$233.08
CHF 62.67
List Price:  CHF 89.54
You save:  CHF 26.86
NOK kr792.28
List Price:  NOK kr1,131.89
You save:  NOK kr339.60
DKK kr501.55
List Price:  DKK kr716.53
You save:  DKK kr214.98
NZ$123.71
List Price:  NZ$176.74
You save:  NZ$53.02
د.إ257.07
List Price:  د.إ367.25
You save:  د.إ110.18
৳8,328.16
List Price:  ৳11,897.89
You save:  ৳3,569.72
₹5,958.01
List Price:  ₹8,511.81
You save:  ₹2,553.80
RM314.25
List Price:  RM448.95
You save:  RM134.70
₦108,236.03
List Price:  ₦154,629.53
You save:  ₦46,393.50
₨19,398.69
List Price:  ₨27,713.60
You save:  ₨8,314.91
฿2,394.21
List Price:  ฿3,420.45
You save:  ฿1,026.24
₺2,465.01
List Price:  ₺3,521.60
You save:  ₺1,056.58
B$426.13
List Price:  B$608.79
You save:  B$182.65
R1,290
List Price:  R1,842.93
You save:  R552.93
Лв131.30
List Price:  Лв187.58
You save:  Лв56.28
₩101,582.03
List Price:  ₩145,123.41
You save:  ₩43,541.37
₪254.54
List Price:  ₪363.65
You save:  ₪109.10
₱4,098.92
List Price:  ₱5,855.86
You save:  ₱1,756.93
¥10,967.38
List Price:  ¥15,668.35
You save:  ¥4,700.97
MX$1,406.50
List Price:  MX$2,009.38
You save:  MX$602.87
QR254.06
List Price:  QR362.96
You save:  QR108.89
P963.25
List Price:  P1,376.14
You save:  P412.88
KSh9,053.20
List Price:  KSh12,933.70
You save:  KSh3,880.50
E£3,568.78
List Price:  E£5,098.48
You save:  E£1,529.69
ብር8,687.63
List Price:  ብር12,411.43
You save:  ብር3,723.80
Kz64,250.82
List Price:  Kz91,790.82
You save:  Kz27,540
CLP$69,297.02
List Price:  CLP$99,000
You save:  CLP$29,702.97
CN¥510.87
List Price:  CN¥729.84
You save:  CN¥218.97
RD$4,243.89
List Price:  RD$6,062.96
You save:  RD$1,819.07
DA9,435.69
List Price:  DA13,480.14
You save:  DA4,044.44
FJ$162.05
List Price:  FJ$231.51
You save:  FJ$69.46
Q536.99
List Price:  Q767.16
You save:  Q230.17
GY$14,580.66
List Price:  GY$20,830.41
You save:  GY$6,249.74
ISK kr9,757.30
List Price:  ISK kr13,939.60
You save:  ISK kr4,182.30
DH701.41
List Price:  DH1,002.06
You save:  DH300.64
L1,291.33
List Price:  L1,844.84
You save:  L553.50
ден4,135.36
List Price:  ден5,907.91
You save:  ден1,772.55
MOP$557.92
List Price:  MOP$797.07
You save:  MOP$239.14
N$1,283.07
List Price:  N$1,833.03
You save:  N$549.96
C$2,564.57
List Price:  C$3,663.83
You save:  C$1,099.26
रु9,479.94
List Price:  रु13,543.35
You save:  रु4,063.41
S/259.51
List Price:  S/370.75
You save:  S/111.23
K282.61
List Price:  K403.75
You save:  K121.13
SAR262.99
List Price:  SAR375.71
You save:  SAR112.72
ZK1,928.73
List Price:  ZK2,755.44
You save:  ZK826.71
L334.62
List Price:  L478.06
You save:  L143.43
Kč1,690.23
List Price:  Kč2,414.72
You save:  Kč724.49
Ft27,882.67
List Price:  Ft39,834.10
You save:  Ft11,951.42
SEK kr772.23
List Price:  SEK kr1,103.23
You save:  SEK kr331
ARS$71,547.27
List Price:  ARS$102,214.77
You save:  ARS$30,667.50
Bs481.59
List Price:  Bs688.02
You save:  Bs206.42
COP$305,890.51
List Price:  COP$437,005.17
You save:  COP$131,114.66
₡35,162.35
List Price:  ₡50,234.08
You save:  ₡15,071.73
L1,769.11
List Price:  L2,527.41
You save:  L758.30
₲543,432.39
List Price:  ₲776,365.26
You save:  ₲232,932.87
$U3,131.93
List Price:  $U4,474.38
You save:  $U1,342.44
zł286.59
List Price:  zł409.44
You save:  zł122.84
Already have an account? Log In

Transcript

Hello, in this video let us try to implement this Miss with validation. So, I will go step by step for step one we should open the entity object and select the business rule. So this to go to 2g developer and start for implementing this okay so now I create ADF application called method validation application has department and employee entity. So now I need now to add a validation in the employee custom validation. So I want to make two type of validation. First, I need to check if the first name equal to the last name just fire in exception.

This is also just for example, you can add depending on what you want in your ADF application. I can add maybe if the salary is greater than seven Seeing souls the department should be between some department range. So, we can add this validation as an entity living and I can add a validation in a specific maybe specific attribute for example phone number size should be greater than maybe nine digit and less than 12 digit. So, we can add something like this is the phone number. So, this now try to follow the first step here is open entity object then select business rule. So now I open the entity object since I will go for the business rule.

This is a business rule of the entity object you can find here, entity validator, this validator will be in the entity level and you will find each attribute here you can add a validator over a specific attribute. Okay, so this is the fittest tips have been Second step is You can add validation specific attribute in the in order entity level as I show you right click over the entity validator or over the attributes and select New validator. So let's now add entity validator, I will add one validator over the entity, which will check if the first name equal to the last name, fire an exception and we can add another entity validation if the salary is maybe greater than 10,000, you should pick only the department may be greater than 50. This is just for an example. So let's now to create a new vertical just as I said, you right click on the entity validator, right click New validator, okay.

There are some built in validators in the entity validator, okay. For example, if you want to check the length of a check the range value if you have a regular expression image to show But let's now try to implement that method you will find here method. So, I will select the year as method here as you can see it will create a method name called validate employees. This is a method name you can go to the failure handler and droid an error message which you will add. So, I can see here is a name will be in maybe in buoy first name rude okay right here error message first name should not be equal to last name this is just holding somewhere but actually in real time it can be done. So, in between first rule and here it will create a method and I press ok you It will ask you a java file is not generated you want to generate it yes generated.

Okay. See if so, what we did so far, we right click over the entity validator and select New validator Zin in that validator window we select a method and we write our own failure handling tap message, then I will go to the entity, Ember, Java class and I will find my method. So, if you go to the Java here, you will find this Java MB class is generated. Open it you will find here you will mess with validate MBE This is a validation method generated here and as I told you it will return a Boolean true or false. This is a this is the last step is this method should return Turning true or false. By default it will turn return true it means the validation will be bought successfully, there is no validation.

So in your values a user will enter dismissal to understand the true, but if you want to dismiss it to validate and stop the user with an error message, this message should return false. So here's our method I need to deal with the attribute I need from this entity I need to get the first name and check the values and I get the philosophy name and choose a value. But as you can see here, there is no first name and last name getter and setter. So to generate the getter and setter of the attribute, you should go to here and in the embeddings entity, Java Plus, you select Edit and you just add include accessors include accessors, it means it will add the old attribute in the Java class and you can deal with this attribute. But it's okay. Save ob now's the Ember close.

You will find here all attributes salary on all attributes first name and last name. Here get it first name, city first name or last name or attribute now has its setter and getter so that you will be able to work with it. So now it's a valid method here. In between I can say that if get, first name, not equal null, cheek first and equal not. And get last name. not equal now and get first name dot equal get to last name.

That case I need to return false return false it means the validation should be fired otherwise it can return true okay. So here is a validate employees method I check is a first name not equal null and last name not equal not and first name dot equal last name is that case return false return false it means this method will is a business rule here, double click this method getting validated in blue we will display this error message and stop the user to continue working or not the data will not be Submit. So, this is the our example is the entity we can add multiple if you want to add another new validator you can add another method Okay. So, we can see here regenerate muscles and we can see here validate employee salary okay in between salary rule and you can see support meant should be greater than 50 if or when salary is greater than maybe 50,000 for example, okay this is another route and the method will be usually did the in between salary and this is error message and type is Miss okay let's stick with this okay.

Now I have two method validator over the entity. If you open here you will hear you will find validated employees employees salary message is generated. So let's send out to add our validation which will be the salary which is the salary so if the if salary also if get salary okay you can see the data type if you go to salary this big dessima So, not equal now and get salary not to or to double value greeters then 50,000 Get department ID is less than 50 okay return defaults. So, as I said here, if his salary is greater than 50,000 the department should be greater than 50. So, if the bottom is this than or equal 50 Why is that his salary is greater than five so 50,000 return false Okay. So now we add two validation methods over one entity and we write our own business our own it check what what do we want to do and if this chick is not meet our requirement, I will return the false to that error message will appear Loser all should fix this add another method attribute but that time it will be over their specific attribute.

For example, the phone number, okay, you can right click over the attribute for number and you can add new validator and I will select here as well method and I will call validate method number and submitted your message will be phone number should we mean nine to 12 cutter doors okay. So this is a phone number for the theater. It's okay. You'll find here for numbers See here credited for number as you can see here, so very little phone number I will check if I can get the phone numbers not equal no and get phone numbers dot length is this night and is a nine or four number look then greater than 12 so we just add here Mike brackets Are you willing to return so here I will validate your phone number so it is a phone number. So here's the value we can take the value of the phone number which will be set.

So sorry, it should be is the string not equal now and lens lens. So here, because it is over the attribute the validate missile will send the phone number which is the user ID, but here because of it is over the entity. So there is no parameter will be set sent to the validator, but because of this is over a specific attribute. So as the validate missile receives the value, which is the user Insert. So you should check the value if not equal null. And if the length is less than nine, all integrators and 12 you should return false it means this is wrong I need the length to be between nine to 12 okay so now we add three Mr data validation method here.

So this is now run and about data's now create first a page Okay, so I create now bitch, this page with has in between four and zero only save or commit and rollback. So let's now run and check this method validation. Okay, so now we run the page. As you can see, this is an in between. Let's now try to check the validation the various validation we said if the first name equal to the last name, I need to display the error message. So for example, this is finished Name Nicolas Nicolas name like exists and press save you will find here first name should not be equal to the last names of addition now is run.

So, this is Rebecca if we add any change first name or last name is different and commit it will accept accept it. So, spec that that again keeps it as it is okay this is a pretty strict now if the first name and last name is equal to each other, as you can see again omit you will find and validation is fired. The second validation is if the seller is greater than 50 k per submit if it is 60 K and the ultimate is less than 50. For example the document is 20 I should get an error message. Yes the document should be greater than 50. The one should be servants and 50 if the salary is greater than 50,000 Okay.

So, now if the salary is greater than 50,000 the budget is 90 so we can make it here 60,000 and now it should be okay. But if you make it 20,000 again make so the salary is okay because it is not greater than 50 if it is 60,000, but the department is 20 or less than 50 you will receive an error message. So, this is is a validation over the whole entity. So, last a validation we did over the phone number. If the phone number size is less than nine and it doesn't Well, I should receive an error message. Let's see.

Here you can see phone number should be greater than nine to 12 characters. So if we added greeters into We'll hear you will see the same validation okay. So into the scope is copy this value and let us now add 1-212-345-6789 10 now should be okay it is okay because it is between nine to 12 it's back again okay so this is how you can write custom message or validate or misheard over in the entity Live ID or is attribute over the entity. So depending on your ADF application depending on your business if you want to write your own custom validator, you can write it in this entity object to the business rule as I show you. So this is how to can create a Mr. Potato Nick is to video.

We will go to Is there another feature so see you Nick is still with you.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.