Thursday, March 23, 2006


Embedding customs Queries into Session EJB 3.0 based on Toplink POJOs




1. Create application workspace HRApps with Struts,JSP,ADF template.



2. Generate Toplink Mapping for project Model and two pojos

Employees.java and Departments.java for offline tables hr.employees,hr.departments.



3.Implement "Serializable" for both of created objects as follows:-






Public class Employees implements java.io.Serializable {

}
. . .

Public class Departments implements java.io.Serializable {

}
. . .





4. Invoke wizard for session EJB 3.0 creation.





Select Toplink POJOs.






Generate all default methods suggested:





Select Remote and Local interface.

Otherwise you won't be able to create "New Sample Java Client"

when working with remote Oracle Database.




Right click on HRSessionBean and select "Create Data Control"



5.Add to HRSessionBean.java:-



public List findEmpInfo(String jobId) {
Session session = getSessionFactory().acquireSession();
Expression exp = new ExpressionBuilder().get("jobId").equal(jobId);
List results =(List) session.readAllObjects ( Employees.class,exp);
session.release();
return results;
}




Switch to Structure Window;-

Right click on "findEmpInfo" node.Select Properties and select remote and local interface.

Recreate Data Control for HRSessionBean.

Create new sample Java Client and add right after
// hRSession.findEmpInfo( jobId ) to HRSessionClient.Java;





String custJobid = new String("IT_PROG");
java.util.List emps = hRSession.findEmpInfo(custJobid);
for (Employees emp : emps) {
System.out.println(emp.getEmployeeId()+ ":" + emp.getJobId() + ": " + emp.getLastName());
}




Run HRSessionBean and then run HRSessionClient . Watch report in log window.





Creating JSF page to perform custom query.



Create search form by dropping an existing method that contains

the logic to find and return the records based on parameters.

This method must already exist on the data control.


This method finds and returns all employees with desired "JobId"
To create the search form, drop the method as a parameter form. Then drop the returned collection as a table to display the results

To create a search form and results table:

1. From the Data Control Palette, drag a find method that takes parameters.

2. From the context menu, choose Parameters > ADF Parameter Form.

3. From the Data Control Palette, drag the return of that method and drop it as any type of table.




Create one more JSF page utilizing HRSessionBean's Data Controls based on automatically generated methods :




Now implement JSF Navigation cases:-





Run time screenshots of both pages of View Controller Project been deployed to OAS 10.1.3 on CentOS 4.1 (Linux) Box :






Sunday, March 19, 2006


Embedding custom Queries into Session EJB 3.0 based on Toplink POJOs in JDeveloper 10.1.3 environment.




1. Create application workspace HRApps with Struts,JSP,ADF template.



2. Generate Toplink Mapping for project Model and two pojos

Employees.java and Departments.java for offline tables hr.employees,hr.departments.



3.Implement "Serializable" for both of created objects as follows:-






Public class Employees implements java.io.Serializable {

}
. . .

Public class Departments implements java.io.Serializable {

}
. . .





4. Invoke wizard for session EJB 3.0 creation.





Select Toplink POJOs.






Generate all default methods suggested:





Select Remote and Local interface.

Otherwise you won't be able to create "New Sample Java Client"

when working with remote Oracle Database.




Right click on HRSessionBean and select "Create Data Control"



5.Add to HRSessionBean.java:-



public List findEmpInfo(String jobId) {
Session session = getSessionFactory().acquireSession();
Expression exp = new ExpressionBuilder().get("jobId").equal(jobId);
List results =(List) session.readAllObjects ( Employees.class,exp);
session.release();
return results;
}




Switch to Structure Window;-

Right click on "findEmpInfo" node.Select Properties and select remote and local interface.

Recreate Data Control for HRSessionBean.

Create new sample Java Client and add right after
// hRSession.findEmpInfo( jobId ) to HRSessionClient.Java;





String custJobid = new String("IT_PROG");
java.util.List emps = hRSession.findEmpInfo(custJobid);
for (Employees emp : emps) {
System.out.println(emp.getEmployeeId()+ ":" + emp.getJobId() + ": " + emp.getLastName());
}




Run HRSessionBean and then run HRSessionClient . Watch report in log window.





Creating JSF page to perform custom query.



Create search form by dropping an existing method that contains

the logic to find and return the records based on parameters.

This method must already exist on the data control.


This method finds and returns all employees with desired "JobId"
To create the search form, drop the method as a parameter form. Then drop the returned collection as a table to display the results

To create a search form and results table:

1. From the Data Control Palette, drag a find method that takes parameters.

2. From the context menu, choose Parameters > ADF Parameter Form.

3. From the Data Control Palette, drag the return of that method and drop it as any type of table.




Create one more JSF page utilizing HRSessionBean's Data Controls based on automatically generated methods :




Now implement JSF Navigation cases:-





Run time screenshots of both pages of View Controller Project been deployed to OAS 10.1.3 on CentOS 4.1 (Linux) Box :