Hello let's now try to write some code in zap view object and see how we can create a bag bean for the page and how you can start writing your own code. here as I can get take on the example we have two page department and in between let's run it and see how it does this page is and after that, we can see what exactly is the code which we can write. Okay, so we have this department page and once you press in mind buoy, it will navigate to another page if you select this it will back again. Okay, so what we can do I can try to write make here benilde step Okay, and I will show you once you select the tab if you want to write some code and it's a second tab, I will add the department as an four. So that we can do some programmatically to the form.
Because we need once you select this department we can write some code behind this selection. And for navigation, we can write some code to navigate instead of just select his outcome from action. And I think I can display some some message from back pain. Okay, so the first step let's try to create here at two steps and and it's believed that the board meeting set of tables will be in as informed. So here is a department page which we have little since a body has been a collection it's select inside this body Your faces that I need to tap now maybe the stable form okay. So I will add a drag this tips table tips table and they can from the data control drag a department size for a shoe navigation, that's fine and Okay.
Here we can track some operation like if we need to create roll from the Department of operation Create insert add do can track commit and rollback okay disable from commit and rollback because we need it always to be enabled okay. So I just created this I can add a new column here sorry a new button here I can all say go to boo wheeze okay. Normally we selected from action here outcome in between temp so that we can go straightaway to be with him because actually the speeches are the same Big flow. If you open here the big flow you find here department and inventory which is department and in between or looks no this is this department in blue so it is the same BG flow which has an outcome called MP temp and the temp. So I can easily select here. And actions select as it will go to the import if case if you want to make some code before you navigate.
So, how you we'll show you how you can write code without selecting it here like this. Okay, so let's start with was, was this action, I need to navigate to another page. But I don't want to write outcome here is action. I need to write to execute some code First and depending on the condition I will decide if I will never get or not. So is that case in section here, you selected it. Okay.
Here you should select the Manage been dimension which is a Java class which you should write your code so you don't have any magic beans you select new and you can see the beat name is the US, Tim and the class name is the use Tim bean and I will put it in the package view to be what is the difference between been under the plus name me name and the class name class name is the main Java class name, but the bean name is a prefix which will be used in the big level 2.2 Java class I will show you it is by default the scope is request I prefer this scope to be request you have another scopes what I need to request because we need to clear the memory wants we need once the object is loaded after the user leave it It should be deleted.
If you want it as a session or in other things you can put the variable in the session as we will see now. Okay now I will create one bean this bean I will make it for this bitch if you need another to access another black bean for another big when can eat its own beat and all beans will be in this package. Okay. So now it will create the class. Okay, here's the method, which you want. I will here navigate Action okay wonders Okay, so let's have a look.
Let's have a look here in the view to pin it create a class. This class now has an action called navigate to action and in the big level here is action. Here you will find go to the action here it select your beam you will find the message here navigate select it and the rest okay. So you will find here, this is the name which we will write once we create is a managed beans This is been named here, navigate to action. If you want to know how you can navigate from how you can know which bean and navigate to the action straight away you can go to the source here. Good source refunds action you can risk control from the keyboard and the receipt which will navigate to the message.
So once now the user press on this go to employee it will call this method. So we can write just to be sure that okay okay. So, here I want to navigate to in belief for example. Let us see here is employee okay if the department ID is equal 70 I need to be able to navigate to the MBE otherwise, always it is the ultimate is 70 don't navigate to Zimbabwe otherwise you can navigate this is an example how to do that So first I need to get the department ID. So, now before we start doing this, let us try to run and see the beach how it is I just now create a bundle step and I add the department as important. So let's run again just to have an idea about the beach how it looks like and I can explain what exactly we need to do okay is this a department table workmen form because both of them has the same iterator so once you select this row 70 wants you here you should be in the same department which you are select, okay.
Okay, so what I need to do is I need to once I Go to the MVP now if I press go to the MVP, I should see now called to navigate them from there it is called this misheard and printed this Okay, so I need now if the department ID equals 70 I should display an error message you can go to this inbox and if I select any other department here and go to employee, I should check if the department not equal to 70 if it is not equal 70 I will navigate you to make this code this business is the code so first thing I need to get the value of the department ID in my bag bean. So to get attribute value from a traitor because we are now one of the department a traitor, I have a method called get attribute from my traitor.
So here I will write our my if you tell dot Okay, I wouldn't be It dot get attribute from iterate This is return an object. So I will write object you should be have an you should have a basic knowledge of Java used to understand what I am talking now. So I right now object call divorced meant ID equal my if you tell the Java class which I created to get attribute from my trader. So, first we need to get the iterator name how you will get a traitor name you will get it from the big definition. So, you go to the big definition, this is a iterator name okay. Okay What is that attribute name which you want to get from this a treat or you should go to the View object goodwill attribute and I need this attribute this is attribute name.
This is how you can get the return name and attribute. Now, let us see the current dip is department ID. Okay we need to check if this department ID if it is not equal to 70 you can navigate otherwise don't navigate and display error message. So I will write if deport meant ID booked equal 70 if is equal to 70 I need to display error message and I should not never get to the But we don't show error message sorry you can we get to be please for the 70 and return no to stop okay if it is most of NT we should return what we should have turns out come here in Tim I would come which we normally set it here commercial a normal city uses MTM instead of sitting straight away here No I will navigate to the back pain and the forms the back pain I will return the outcome.
Okay, so let's have a look in this. How in this code now we know understand how You can first create a management, how you can map one of the button action to the function in between how you can get value from my traitor to check it and how you can display your message and how you can navigate to one or bitchu it does now try to this this, see how it all works? Okay so select now bill is 70 apartment couldn't be we now sorry you can navigate to me to you for the passivity. See now you will display an error message and you will not be able to navigate. But if we select any other department and try to press here, it will navigate correct. So this is an example how to can get value from the current a traitor how to get to this Because it's a table once you select the row the traitor will be marked as a as a current row because here in the table there are here in the behavior there are selection listener.
So, it will make zero as a current throw in a listener at iniquity of component it means it is something related to the backbone you can you can run a Java code to make this to handle this listener. So, it once you drag any table I just give you an example if you sit at the mark as single row, it will enable that once you select a row this row will be marked as a current row for a traitor. So, is the bag been once you sit get a tribute from a traitor. It will gets the current row value. So now I need after this example, as I said, you know able to override the actions or the Actions button, you can display your message you can get value from the current draw of the iterator, you can navigate to another page. So, from the negativity I'll give you another example.
So see you next video.