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
€64.51
List Price:  €92.16
You save:  €27.65
£54.93
List Price:  £78.48
You save:  £23.54
CA$95.68
List Price:  CA$136.70
You save:  CA$41.01
A$105.53
List Price:  A$150.76
You save:  A$45.23
S$94.49
List Price:  S$134.99
You save:  S$40.50
HK$546.56
List Price:  HK$780.84
You save:  HK$234.27
CHF 64.08
List Price:  CHF 91.55
You save:  CHF 27.46
NOK kr740.69
List Price:  NOK kr1,058.18
You save:  NOK kr317.48
DKK kr481.62
List Price:  DKK kr688.07
You save:  DKK kr206.44
NZ$114.33
List Price:  NZ$163.34
You save:  NZ$49
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.19
৳8,200.05
List Price:  ৳11,714.86
You save:  ৳3,514.80
₹5,813.28
List Price:  ₹8,305.04
You save:  ₹2,491.76
RM329.26
List Price:  RM470.40
You save:  RM141.13
₦102,276.30
List Price:  ₦146,115.27
You save:  ₦43,838.96
₨19,447.66
List Price:  ₨27,783.57
You save:  ₨8,335.90
฿2,561.05
List Price:  ฿3,658.80
You save:  ฿1,097.75
₺2,254.58
List Price:  ₺3,220.97
You save:  ₺966.38
B$361.64
List Price:  B$516.65
You save:  B$155.01
R1,289.17
List Price:  R1,841.76
You save:  R552.58
Лв126.12
List Price:  Лв180.18
You save:  Лв54.05
₩95,655.33
List Price:  ₩136,656.33
You save:  ₩41,001
₪256.11
List Price:  ₪365.88
You save:  ₪109.77
₱4,073.73
List Price:  ₱5,819.86
You save:  ₱1,746.13
¥10,984.58
List Price:  ¥15,692.93
You save:  ¥4,708.35
MX$1,168.81
List Price:  MX$1,669.81
You save:  MX$500.99
QR254.92
List Price:  QR364.18
You save:  QR109.26
P949.81
List Price:  P1,356.93
You save:  P407.12
KSh9,122.85
List Price:  KSh13,033.20
You save:  KSh3,910.35
E£3,298.27
List Price:  E£4,712.01
You save:  E£1,413.74
ብር4,016.76
List Price:  ብር5,738.47
You save:  ብር1,721.71
Kz59,376.64
List Price:  Kz84,827.41
You save:  Kz25,450.77
CLP$63,455.03
List Price:  CLP$90,653.93
You save:  CLP$27,198.90
CN¥497.66
List Price:  CN¥710.97
You save:  CN¥213.31
RD$4,116.79
List Price:  RD$5,881.38
You save:  RD$1,764.59
DA9,410.57
List Price:  DA13,444.25
You save:  DA4,033.68
FJ$158.71
List Price:  FJ$226.74
You save:  FJ$68.02
Q543.03
List Price:  Q775.80
You save:  Q232.76
GY$14,626.09
List Price:  GY$20,895.31
You save:  GY$6,269.22
ISK kr9,672.61
List Price:  ISK kr13,818.61
You save:  ISK kr4,146
DH697.32
List Price:  DH996.21
You save:  DH298.89
L1,240.19
List Price:  L1,771.78
You save:  L531.58
ден3,973.31
List Price:  ден5,676.40
You save:  ден1,703.09
MOP$562.57
List Price:  MOP$803.71
You save:  MOP$241.13
N$1,284.81
List Price:  N$1,835.52
You save:  N$550.71
C$2,572.99
List Price:  C$3,675.86
You save:  C$1,102.87
रु9,296.83
List Price:  रु13,281.76
You save:  रु3,984.92
S/261.34
List Price:  S/373.37
You save:  S/112.02
K271.67
List Price:  K388.13
You save:  K116.45
SAR262.44
List Price:  SAR374.94
You save:  SAR112.49
ZK1,865.84
List Price:  ZK2,665.60
You save:  ZK799.76
L320.98
List Price:  L458.57
You save:  L137.58
Kč1,589.64
List Price:  Kč2,271.01
You save:  Kč681.37
Ft24,759.44
List Price:  Ft35,372.15
You save:  Ft10,612.70
SEK kr746.68
List Price:  SEK kr1,066.73
You save:  SEK kr320.05
ARS$62,326.79
List Price:  ARS$89,042.09
You save:  ARS$26,715.29
Bs483.06
List Price:  Bs690.12
You save:  Bs207.05
COP$270,493.43
List Price:  COP$386,435.76
You save:  COP$115,942.32
₡35,841.38
List Price:  ₡51,204.17
You save:  ₡15,362.78
L1,727.58
List Price:  L2,468.08
You save:  L740.49
₲525,820.15
List Price:  ₲751,203.84
You save:  ₲225,383.69
$U2,690.36
List Price:  $U3,843.53
You save:  $U1,153.17
zł274.38
List Price:  zł391.99
You save:  zł117.60
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.