WebLogic Platform Tour Guide
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
In this part of the Tour, you (new employee John Smith) view your employee information. Along the way you will learn how the application uses a built-in database control to simplify access to employee information from the Employee Information database.
Follow the steps described in Step Through the Tour and review the concepts described in this section to learn about:
Note: In Logging In to the Avitek Corporate Intranet, you logged in to the Avitek corporate intranet as John Smith, the new employee. Currently, you are viewing the Employee portal.
Your employee information is populated automatically when you log in. For example, you can view the employee profile for John Smith within the Employee portlet.
WebLogic Workshop provides a set of built-in controls that make it easy to access enterprise resources, such as Enterprise Java Beans (EJBs) and databases, from within your application. The control handles the work of connecting to the enterprise resource for you, so that you can focus on the business logic to make your application work.
Most of the built-in controls are customizable controls. That is, when you add a new one to a project, WebLogic Workshop generates a Java control extension (JCX) file that extends the control. In some cases, such as with the Database control or JMS control, you can customize the control by adding or editing methods defined in the JCX file. Others are customized for you, as with the EJB control, which is customized based on the EJB the control will be accessing.
WebLogic Workshop makes it easy to use a built-in control: click Add from the Data Palette window when working in Design or Flow View, and then select the desired control from the drop-down list. You can create a control file:
jcx
extension to the same folder as the file that is currently open in Design View. The Control Editor is a graphical tool that enables you to design a control, such as the UsersDBControl
database control shown in the following figure.
The following table describes the Control Editor tools shown in the previous figure.
Create, view, and edit control files in your portal application projects. The names of control files end in |
||
Add methods, callbacks, variables, and so on, by dragging components from the Palette window and dropping them onto the Design View canvas. The options available in the Palette window depend on the type of control you are building. |
||
Set properties for the currently selected control component. You can select a control component by clicking on it in the Design View canvas or by selecting its name in the Document Structure window (described below). |
||
View a summary of the Java entities that make up the control (see Figure 3-2). The summary includes the Java classes, methods and signatures, variables, and inner classes for the control. You can select a Java entity in the Document Structure window by clicking on it. When you select a control method, it is selected in the Design View canvas and you can edit its properties in the Property Editor window. You can double-click on a Java entity to jump to its code location in Source View. |
The following figure shows the Document Structure window for a database control.
Figure 3-2 Document Structure Window for a Database Control
To learn more about adding built-in controls:
When the Employee intranet portal is loaded, the UsersDBControl
database control connects to the employee information database to retrieve the employee profile for the current user.
A database control is one example of a built-in Java control. This type of control makes it easy to access a relational database from your application. You simply issue SQL commands to the database and the database control performs the following tasks on your behalf:
When you add a new database control to your application, you specify the following:
View the UsersDbControl
database control in WebLogic Workshop by performing the following steps:
The UsersDBControl
database control and the methods associated with it are displayed, as follows:
The database control provides a number of methods for accessing the employee information database.
An instance of the UsersDBControl
database control, m_DBCtrl
, and the methods associated with it are displayed on the right-hand side of the page flow.
The m_DBCtrl
instance is used to look up the current user and populate the InfoForm
form bean with the employee profile information.
HttpSession sess= getSession();
HttpServletRequest req=getRequest();
joindb.UsersDBControl.User user= null;
.
.
.
user = m_DBCtrl.lookupUser(empId);
.
.
.
if(user==null)
return new Forward( "theFirstPage" );
else {
sess.setAttribute("employeeid",user.employeeid);
sess.setAttribute("employeename",user.employeename);
sess.setAttribute("ssn",user.ssn);
sess.setAttribute("departmentid",user.deptid);
sess.setAttribute("mgrname",user.mgrname);
sess.setAttribute("dateofhire",user.dohire);
sess.setAttribute("salary",user.sal);
sess.setAttribute("officeaddress",user.address);
sess.setAttribute("homephone",user.homephone);
sess.setAttribute("businessphone",user.bussphone);
sess.setAttribute("position",user.position);
sess.setAttribute("email",user.email);
}
return new Forward( "theFirstPage" );
}
.
.
.
protected Forward UsrInfo(InfoForm form)
{
return new Forward("success");
}
Before proceeding to the next step in the WebLogic Platform Tour:
![]() ![]() |
![]() |
![]() |