Hello, in this video I will show you how you can create a dynamic EDF component at runtime. For example, if you have a system menu exists in the database and you want to display a dynamic menu, so you need to get it from create the menu for in at runtime, depending on what existing database or if you want to create a dynamic tab if you want to have tab should be created from data coming from the database at runtime. So in general, I will show you in this video how you can carry it IE dynamic if component in your page at runtime. I will give you two example in this video. So in this course, I will first I create this HR database schema tables. I create two tables won't call main system menu and one call sub menu you in the in this course resource in the beginning of this course the there is an object script, you will find the script which would create this two cables in your HR.
What I need to do is I need to add here my main menu menu has three column is this is for the ID, this is a menu description which should appear in the main menu here and active if this active or not active, you can control if you want to disable it or enable it. So it does create some sample menu in our system and see how how we can display this menu at runtime. So first, I will create here for example menu ID menu description we can call it lookups active maybe why To search why three transaction Why? Okay, this is I have this three menu main menus and in the sub menu here that has add sub menu for each of this big menu. So menu one for the parent which is one is a lookups we can add some menu description like four minutes so menu action tips.
This is movies a menu option which will navigate to the beach was would come depths submenu active yes okay let's add another one for lookups call Emily's action and why three will be for the main mirror to which will be searched we can see search okay so here I create for each beer on the menu to beech forest we're on to will have a look up which is the bark missing Bay employees This is for search this is for renewed automate or numeral II is just for a simple sample example. So let us know try to explain in general How you can create a dynamic PDF component at runtime. After that, we will do this example. So, let us create a symbol symbol pitch Okay. Now, we need to know how we can query any PDF component at runtime. So the first thing you have Farish to know which clause or is this component will be present in in the Java class.
So for example, if I need to insert a menu, a few menu, so I need to know is this if menu is what Exactly is a class which map to this if mean you show how to do this. So first I will add the component which I need to create it at runtime. So in our example I need to create a menu so let's add menu Okay, let's look at menu bar mean v menu bar will appear on but we will add a menu inside it. menu. So now I to create this menu in a Trump time. So, how you can do this.
First I need to bind this component to the backbeat. So, I will create a bean here, my P my bean And I need to create a vertical menu combo. So, as you can see here, it creates a rich menu. So now I know to Create menu item type I have to create object of reach menu, Oracle ADF, view rich component rich rich menu. If you want to add the bottom at runtime, which clause Okay, I need to add a button at runtime I will add now a button then I will go to the binding and let us bind this bottom and see what actually is a crossword we'll create it create rich bottom. So the first thing you need to know is what is class the ADF class which represent your component which you want to create it at runtime.
So now we know to Create Menu all you need really menu. If you want to know what is the menu item, which is a sub menu in our sample menu items, so I would find menu items and did we know what actually sis will represent? It should be rich menu, which command menu item. So, any component you want to create it dynamically, you have to first fight it to know which clause if you notice it's a clause, no need to bind it just just for your information after that, do you need actually this component at all in our pitch? Okay, because the first thing we did is to know which clause Java class I need to use to create the component at runtime. This is the first step second step.
You should have a component in your page which will contain your body dynamic component. For example, in my example here, I need to create a menu at runtime. So, I need to put a component in my beach, which will be the parent of this dynamic component which I will create at one time. So I will add here, menu bar, this menu bar will will be my parent component, which I will create dynamically, the menu and the menu item items as a child as children to this menu bar. So what I should do with this parent, I should bind it in the back. So I will bind this menu bar by beans so I could call it parent menu bar.
Okay, So, this is the second step again first step just to know what is the class name of the component which you should use to create the component type. Second thing, you should add a beer on component in your page and the binds is parent component as an object in a baggie. Now, we can start creating a component at runtime. So for example, if I need to create some menu now, let us make it static. I will not connect to the database but just the statics to create some menu inside this show for what what you should do is create here a function private, void, Kitty dynamic menu and we can call this function From the constructor or from anywhere now I need in this code I need to create a dynamic menu give some space here okay. The first step you need to get my parents my bill which I added here in beach and I binded it in their back pain, so I need to get this parent first.
So I will say parent but what inside this parent you will find here at all Get the children what is this getting the children it will get the list of component which is inside this parent. Currently, there is no component. So this list will be null. Not not the site is zero dot get Sheldon. As you can see it is a return list of UI component. So this is our list of children.
So we can't call here. List UI component. My sure drink equal. If you want to exactly know what it is, you can go to get children here. You'll find this list UI component you can copy it and put it here. So this is the object which the bureau will return.
So now I have a list of my children. Let's import this show for your to do. list and UI component will be Java two trees to component Ok so now I get a list of my children I need to create this children first after that I will add it to this list. So how we can do this now I need to create menu or new now it called rich menu. So I will create object of rich menu first or menu one equal new rich human now I will create object of Richie Rich menu okay which should be added inside this menu bar. After you create an object to fish menu you should set the attribute same like if you have a menu here what what actually you will set if you have menu here.
If you add menu so what you actually use it you will see the thickest The description should appear so here I will set the tick is to sit thickest be lockups. Okay, this is all what I need to do it now for this menu it is limited. Just I just want to show you how you can create a menu at runtime so I create object of Ritu menu and I set the tickets to be lookups after that I need to add sub menu inside this menu. Okay, so to create sub menu, we know switch command menu item. It will add menu item inside this menu. So I will create rich command menu item.
Tip equal new, rich mode menu item and tip to city tickets You bought mints and I need to create another menu item inside this menu one or look up score in Billy's and he should be m after that I need to add this to object inside this. So I will go to the menu one dot get a chill, drink booked looked at I need to add depth and all you need to add it okay so now I create one menu called lookups After that accurate tool menu item, and I add, I get his children off the menu one, dip one gets shaded one and after that I should add the blue one to my appearance. So actually no need to write this here. Right now, we can straight away edit. After you create your menu, you can go here and say get my parent component which is this to get children to add and I will add my menu one.
Now we created one menu in my parent component. Okay, so before we start running, we just need to make two changes First, I need to check if this is not null. should create an object okay. So I will just add if condition. If it were on the menu bar component equal equal not If it is not, it means that he still didn't create this parent component it could just be on the component. So, I will create it after that, I will add the choice otherwise I will get null pointer exception if this object is null.
Second thing I need to do is I need to call this function is the constructor. So, I will go to the constructor here and I will call this function in the constructor. If you want to call it only one time, to be sure it is only one time is rubbish not every time you can right here, if phases contest if contiguous equal if this is contiguous This is if this is contiguous dot get current instance after that we can see if it if contest.is post back. so we can write here if not post back you can call this just to be sure that it will call only one time at the beach because the bean of this is a request been so every action will go to constructor, but if you are in the same page and you make any action, it this this postback will return true.
So, this not it means it will just enter here only one time. So, now, we can use this in a constructor to call my dynamic function and in dynamic function here Create rich menu with stickers to lookups insights this rich menu I add to I get Should I add two component one is department here and second is so it should be in the city tickets here and after that I will add two components inside the menu which is department and after that I will get the beer on and the chick if it is not I would create your component otherwise I will get shouldn't add the main menu one. So this has now run this run this application and check if this menu will generate it at runtime or not. Okay so as you can see here, the lookups menu is created and there are departments and employees A menu is created at runtime.
So this is how you can in general, create a video component at runtime and gets the children in this component and try to work in this component. Nick is the video little symbol with our custom menu. So see you next to it. You