Hello, in this video I will show you how you can create a converter and how you can use it in your EDF application. So, here I have created simply div application with one entity in Bluey and one object in movie. Now try to create a converter. So, to create a converter you should create is application source I will create a Java class I will call this mobile phone converter in your EDI fabrication you can define mini converter as you want. And I will edit in there. Go on there towards package and I will press OK.
So, it does remove this constructor So tokita converter you have to implement this interface called converter. So, I will call here implement in converter and this is Java two phases Yes, so, I would import which phases converter, this is what I need Java which phases with converter. So, to implement this interface converter you have to implement some methods get as object and get as string. There are two methods here. This is when your user set the value was there's an interest of value and set it to how you want to convert it. And this is return the value to users This is word here is a verb just function.
So here you should write what actually you want to do. Once the user set he is a strength this string object will be the value which is the user will send it to you. And you can write your code here. So I will write here for example, if the string is equal equal null, or its string trim equals No. Return not. Okay.
Second thing is, I need to be sure that the user enter a mobile number like 08. And after that roar, eight liters So total should be 10 1-234-567-8910. So I need to be sure that the value which the user will enter has attend corrupt if it is less than or more than I need to splay an error message. So, to do this I hear make a check if the string length is not equal to 10 I need to display an error message and I would throw new converter exception and I would place a message. This is if you want to stop and split error message to the user. If the user tries to enter the value is not equal zillions whose value is not equal to 10.
I need to say you have entered one number in the format you have to return number in this format a and I will display this message okay. So What after is a user enter this format all I need to do is I need to add c five three. So, what I will can do I can say is drink value equal I need to substring this value by removing this zero and as 343 instead of this zero, so we can say string dot substring from one to 10 01 and till 10 So, it this is what returned from end to end offset number six Then we can return here 353 philosophy okay. So, this is how we can handle the value which is a user will send to me. So, once the user sent me a string I will check if it is null or if it is like empty I will return null then I will check the length of the value if it is not equal to 10 I will return an error message.
So, if the user interact corrected values then I will substring the value or you mean from the second letter to the end and I will return 343 and I concatenate with value. This is if when the user sits of it, this is when the value is called back from the database and you want to display it to the user. So, first I need to convert this object to or we can choose an object. So, I will say if object, this is object we should return from the database, if an object equals equal null return null string value equals string dot value of object a will convert convert this object to string. So that I can make substring. So I need now the value which will return the from the user to be like 3538.
And then eight Number it will be like this. So what I need to do I need to remove the first three letters and the race it was zero. So I will say think number equal value dot substring IE to substring from 012 from two to 1-234-567-8910 1112 to 12. Zed case I will return this signal we need to add zero so I will return zero loss in Okay. So, now, again if you want to create a converter you have to implement the converter interface. Once you implement second converter interface, there are two override method you have to override one method, which is a user will set the value.
So you can write your own business here once the user sees the value, and it will return the value which you want to store it in the database. And there are other function here, which will read the value from the database and you write your code and the returns a value which is the user want to see it in a bitch. This is the two things to function in the Convert. So once you finish your converter now, the two methods you do to configure your EDF application to use this converter, you should open the faces config file go to the overview Tip and the overview tab, you will find here converter in the converter here, I need to add my converter. So, I will press add here give any name, I will call it mobile coupon vector and the class here I need to go into my class.
So, I will press edit here and search for my class which is mobile phone This is my phone convert and I will see. So, this is the second step. So, after you can create your class converter, you go to the faces config in overview converter you add your converter. Now, let us create a symbol if page and I will show you how you can use this converter. So, converter just to blank Beach and lettuce at Emily drag the blue is a four a four way navigation and press OK. case here go to converter Here you will find here there are a phone number I need to apply my converter in this phone number. So, to do this, I will right click here insert inside in both tests gsf converter then you will find here a list of converters you should find your converter here You'll find the mobile converter is added here in the list and press OK.
It looks as though there is a bug here I can write it here. So I will go here in the source and I can edit here like this, we can write here if converter converter ID, and we can find Mauer by converter and we can cause clicks. So it will be like this. So, we add here if the converter inside the phone number and we and we add this converter inside the phone number and we select our mobile convert let us hear you just has as commit to that if we commit the change we should choose C was a change in the database and let us start Okay, so this is our phone number. Start was in Bluey 454. Let us have a look in the table in Bluey.
454 Has no question Phone number okay. So, let us enter some phone number like this and press commit you will find here your message which you wrote in the converter that you have to enter phone number in this format this is the error message we wrote in zip converter if the user interface number was size or the length is less than 10 So, let's enter the correct format number so 0812345678 and that is safe okay. So, it is saved. Let us have a look here is a database how it is stored So, it is sort like three five c 8123456 So, actually it is stored like this, but it appeared like this okay. With a beer like this, we can all go for the next we will add 0887654321 little save Have a look here it is soon as 353878771. So, so let us now try to close this again and reopen the beach again the need to see how that will be returned from the database.
It's in the box there's three here so I think there was something wrong. We did insert return. So I will come back again to the converter and check the value which is June with substring two To 12 01 to look so key for me, but what can we do we can say display xev value here. Okay, and we can display the number here and let us check that's a value which is returned it Okay, so let's stop and run it again. Okay, so let's have a look here. You will find the value is coming like this and once we substring Okay.
So, let us try to substring three because it should we should remove this. So, this is substring it from three to 12 and this it again ok so, now it looks okay you will find here, this is a value which is come from the database, then I remove this 353 and return only these values in a concatenate zero. This is just how you can just to trace where is exactly the error. So, now, I can see here, my phone number 08 and they should enter like this, but actually in the database is stored Like this format this is how you can use a converter or catalytic converter and the hell you can use it in a fabrication and you can do whatever in converter you want in your PDF application if you want a converter for a male, for example you need to install all is a name but you want to display the full format of the email address.
Anything you want to display some format and soon in a different format. You can create your own custom converter, you can configure it as a face config. Xin is a video page use if converter and point to your converter ID. You can see the video I will show you another feature. So see you next video.