Graphic Design

WebLogic Workshop, WebLogic Platform, and the J2EE Landscape

WebLogic Server has been on the cusp of new technologies and specifications in the J2EE and application server space for years and is the front runner in terms of features and performance. WebLogic Workshop 8.1 offers a full suite of tools for developing sophisticated enterprise applications. Get the basics on this IDE, including the MVC pattern. (From BEA WebLogic Workshop 8.1 by Albert J. Saganich, Jr., et al., Sams, 2004, ISBN: 0-672-32622-1.)

J2EE provides a component-based architecture for developing an enterprise application quickly and efficiently. This component architecture divides application logic into manageable units. WebLogic Workshop builds Web applications based on the Model-View-Controller (MVC) pattern, which helps separate an application's activities into functional areas. MVC also enforces security on the data—the Model part of MVC—which means that data shouldn't be allowed to change unless it's processed through a business process. Controllers are objects responsible for routing requests to the appropriate business component to process the data and forward it to the View component for display. Workshop supports the MVC pattern by implementing a component-based architecture.

The View Component

In J2EE, JSPs are used as the View component. JSPs are components used to generate dynamic content as a response to a client request. The Java code for generating the dynamic presentation is written within tags, which are the standard tags provided by the JSP specification or custom tags you have developed.

Workshop enables you to build these JSPs through GUI-based editors and also provides a set of custom tags, known as the NetUI tag library. This library contains tags for most of the popular features used when developing JSPs, such as creating links, buttons, tables, and so on. Without this library, you would have to write a considerable amount of code to build these elements on your own, but with the NetUI library, these tasks are quick and straightforward.

When you create a JSP in Workshop, you don't have to enter the code for using these tags. Workshop offers a number of ease-of-use features, such as name completion and tag palettes. You can simply drag a tag from one of the palettes to the JSP.

The available NETUI tags and details on how to use them are explained in Chapter 7, "Using the NetUI Tag Library Toolbox to Develop Sophisticated JSPs."

The Controller Component

In J2EE, servlets act as Controllers that route requests to the appropriate Model component. Normally, you must hard-code the application flow in these components to create navigation logic, which makes it difficult to adapt to change.

Workshop introduces a framework called Page Flow that acts as a Controller in the MVC model. A Page Flow is an easy-to-use GUI-based tool for connecting pages with snippets of navigation code known as actions. Actions are small bits of decision logic built visually through drag-and-drop that can access underlying Model data to control page navigation. Application flow is stored as annotations, and the code is generated at runtime. Using Page Flows, discussed in more depth in Chapter 4, "Developing with Page Flow," makes it easy to adapt to change.

The Model Component

In J2EE, EJBs are used for processing data and form the Model component of MVC. There are four kinds of EJBs:

Stateless session beans are short-lived synchronous beans that do not maintain any client information. All instances of the same stateless session bean are identical.

Stateful session beans are synchronous and maintain some client information, but only for a temporary period. This information is not stored persistently and is lost when the bean instance is destroyed.

An entity bean represents persistent data. The data is saved before the bean instance is destroyed.

Message-driven beans(MDBs) are stateless beans that allow business components to receive messages asynchronously.

For Modelcomponent support, WebLogic Workshop introduces a new type of component known as a control. Controls are completely integrated into the Workshop environment and have a predefined set of methods and properties that specify the business logic. Two types of controls can be used in Workshop:

Built-in controls, such as rowset controls, have predefined methods for creating, reading, updating, and deleting records from a database.

Custom controls can be created to leverage complex business logic across different applications.

The Workshop Framework compiles and runs these controls as EJBs. Chapters 6, "Introduction to WebLogic Workshop Controls and Components," and 8, "Advanced Control Development," examine the different types of controls that can be used in Workshop for processing data.

Applications built with Workshop follow the J2EE standards for packaging. All View and Controllercomponents are packaged as a Web Application Archive (WAR) file, and all Modelcomponents are packaged as a Java Archive (JAR) file. The entire application is deployed as an Enterprise Archive (EAR) file. Chapter 3, "WebLogic Workshop Application Development Basics," explains the directory structure Workshop uses when building applications.