Online Help for the ADF JavaBean Sample Application

What does this sample show?

The goal of this sample application is to demonstrate how to use ADF databindings with Java classes and Java Beans.

Why is this important?

The sample shows that ADF databindings can work with plain JavaBeans and Java Classes.

 

Key Points

 

How was the Data Control for hrFacade built ?

Note:- hrFacade.java, beanDept.java and beanEmp.java are custom created Java classes

 

How was showBeanData page built ?

This page shows you a master-detail coordination with the data coming from collections in Java Classes. After creating a datacontrol for hrFacade class in the model project. View project was created with Struts as one of the technology scopes.

How was this UpdateDept page built?

Flow : In the showBeanData JSP page, user will click on Update link in the Departments table, which will bring updateDept JSP page. UpdateDept JSP page has an input form for the Departments information, with the current selected department information in it. User can update the Department name and click the submit button. Clicking on the submit button will refresh the deptsCollection and bring back the user to showBeanData JSP page where he can see the updated values.

What did we do ?

When the user clicks on the update link, setCurrentRowWithKey operation helps to get the current/selected row by doing a post back to the same showBeanData Data Page. By adding a new event into URL, showBeanData action will forward to next Data Action which has forward name updatedepartment from showBeanData.

 

 

What did we do so far ?

We created a new Data Page with Departments Input Form.

What did we do so far ?

We dropped the editDept business method on the Data Page, so that it will get invoked when the user hits the submit button. By modifying the values of the parameters, we are going to the values submitted in the page via the HttpServletRequest.

 

What did we do so far ?

We created a new Data Action and dropped execute operation, so that the departments collection can be refreshed with the new values. After the refresh, user is taken back to the Master- Detail page, where he can see the updated values by navigating to that bean record.

 

What did we do?

By adding the above code, we are making sure that the business method gets triggered when the user hits the submit button in updateDept JSP page.

 

How was DeleteDept page built ?

What did we do?

We created a DataAction, that will call the deleteDept business method, after the business method is invoked, deptsCollection is refreshed and the user is taken back to showBeanData JSP page.

 

 

How was CreateDept page built ?

 

What did we do?

We created a Data Page which will invoke the business method to create a new department in the collection. Once the business method is invoked, collection is refreshed and user is taken back the showBeanData screen.

 

 

How was this UpdateEmp page built?

Flow : In the showBeanData JSP page, user will click on Update link in the Employees table, which will bring updateEmp JSP page. UpdateEmp JSP page has an input form for the Departments information, with the current selected employee information in it. User can update the employee name and click the submit button. Clicking on the submit button will refresh the Collection and bring back the user to showBeanData JSP page where he can see the updated values.

What did we do ?

When the user clicks on the update link, setCurrentRowWithKey operation helps to get the current/selected row by doing a post back to the same showBeanData Data Page. By adding a new event into URL, showBeanData action will forward to next Data Action which has forward name updateemployee from showBeanData.

 

 

What did we do so far ?

We created a new Data Page with mployeesInput Form.

 

What did we do so far ?

We dropped the editEmp business method on the Data Page, so that it will get invoked when the user hits the submit button. By modifying the values of the parameters, we are going to get the values submitted in the page via the HttpServletRequest.

 

What did we do so far ?

We created a new Data Action and dropped execute operation, so that the departments collection can be refreshed with the new values. After the refresh, user is taken back to the Master- Detail page, where he can see the updated values by navigating to that bean record.

How  was deleteEmp page built ?

What did we do ?

When the user clicks on the delete link, setCurrentRowWithKey operation helps to get the current/selected row by doing a post back to the same showBeanData Data Page. By adding a new event into URL, showBeanData action will forward to next Data Action which has forward name deleteemployee from showBeanData.
 

 

What did we do?

We created a DataAction, that will call the deleteEmp business method, after the business method is invoked, deptsCollection is refreshed and the user is taken back to showBeanData JSP page.

How was createemp page built ?

What did we do ?

When the user clicks on the delete link, setCurrentRowWithKey operation helps to get the current/selected row by doing a post back to the same showBeanData Data Page. By adding a new event into URL, showBeanData action will forward to next Data Action which has forward name deleteemployee from showBeanData.

What did we do ?

We created a JSP page, where in the user can select the department number from a drop down list box, enter employee number and name and hit the submit button.

What did we do ?

We created the forwards between showBeanData and createEmp Data pages and dropped the business method on createEmp data page, so that it gets invoked when the user hits submit button in createEmp JSP page.

/* * Get the index value for the selected deptno in the list
* find the control binding and get the actual deptno based on the index
* Get the values of empid and empname from httpservletrequest
* Create an arraylist and add all the parameters to the arraylist
* call the custom method
*/
public void onAddEmp(DataActionContext ctx)
{
int selIndex = new Long(ctx.getHttpServletRequest().getParameter("deptsCollection")).intValue(); JUCtrlListBinding dc = (JUCtrlListBinding)ctx.getBindingContainer().findCtrlBinding("deptsCollection"); Object newDeptno = dc.getValueFromList(selIndex).toString();
String deptno = newDeptno.toString();
String empid = ctx.getHttpServletRequest().getParameter("empId");
String ename = ctx.getHttpServletRequest().getParameter("empName");
ArrayList al = new ArrayList();
al.add(deptno);
al.add(empid);
al.add(ename);
ctx.getEventActionBinding().setParams(al);
ctx.getEventActionBinding().doIt();
}

What did we do?

With the above code, we are getting the index value for the department number selected by the user in createEmp JSP page, finding the actual department number along with employee number and name. Once the information is captured the parameters are added to an arraylist and custom business method is invoked.