Skip navigation.

WebLogic Platform Tour Guide

  Previous Next vertical dots separating previous/next from contents/index/pdf Contents View as PDF   Get Adobe Reader

Viewing Employee Information

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:

 


Step Through the Tour

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.

 


Using a Built-In Control

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:

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.

Figure 3-1 Control Editor

Control Editor


 

The following table describes the Control Editor tools shown in the previous figure.

Table 3-1 Tools for Designing Controls 

Callout #

Use this tool...

For this task...

1

Application Window

Create, view, and edit control files in your portal application projects. The names of control files end in .jcx.

2

Design and Source Views

Design your control in this area.

3

Palette Window

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.

4

Property Editor Window

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).

5

Document Structure Window

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

Document Structure Window for a Database Control


 

To learn more about adding built-in controls:

 


Reviewing the Employee Information System

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:

  1. Variable name for the control.
  2. Whether you want to add a new database control file or reference an existing one.
  3. Data source to which the control is bound (if you are creating a new control file in step 2).

View the UsersDbControl database control in WebLogic Workshop by performing the following steps:

  1. In the Application window, expand the e2ePortal/JoinDB/joindb folder, as shown:
  2. JoinDB Folder


     
  3. Open the database control by double-clicking UsersDBControl.jcx.
  4. The UsersDBControl database control and the methods associated with it are displayed, as follows:

    UsersDBControl Database Control


     

    The database control provides a number of methods for accessing the employee information database.

  5. Open the Employee page flow file by double-clicking e2ePortalProject/employee/Controller.jpf.
  6. Select the Action View tab.
  7. 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.

    UsersDBControl Database Action View


     
  8. Select the Source View tab.
  9. 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:

  1. Close all open files by choosing File—>Close Files
  2. To conserve screen real estate, temporarily minimize the WebLogic Workshop window.

 

Skip navigation bar  Back to Top Previous Next