Programming through Managed Beans:
Objective: Show error when user wants to view employees of a manager (with manager id 201)
Let’s create a page with two tabs (using PanelTabbed Layout) as below. Let’s use the Master-Detail functionality to show the Managers on Tab-1 and Employees on Tab-2.
On View Employees button on the Managers tab, let’s update the action listen.
Let’s create a managed bean(if doesn’t exist already) and a method for the above button.
Now, open the managed bean class and edit the method(NavigateToEmps) as below:
public Object NavigateToEmps() {
Object managerId = MyADFUtil.getAttributeFromIterator(“DepartmentsView1Iterator”, “ManagerId”); if (managerId.equals(201)) { MyADFUtil.showErrorMessage(“Employee Details are classified for this manager”);return null;}MyADFUtil.putInSessionScope(“DepartmentId”, MyADFUtil.getAttributeFromIterator(“DepartmentsView1Iterator”, “DepartmentId”));return “Emps”;}
Object managerId = MyADFUtil.getAttributeFromIterator(“DepartmentsView1Iterator”, “ManagerId”); if (managerId.equals(201)) { MyADFUtil.showErrorMessage(“Employee Details are classified for this manager”);return null;}MyADFUtil.putInSessionScope(“DepartmentId”, MyADFUtil.getAttributeFromIterator(“DepartmentsView1Iterator”, “DepartmentId”));return “Emps”;}
It’s time to run the page and see the error message for the manager with id 201.
ليست هناك تعليقات:
إرسال تعليق