Interface Layer

To better insulate JSPs from the use of JPOs, an interface layer must be provided. These light-weight wrappers hide ENOVIA Studio Customization Toolkit details from the JSP programmer and provide a more natural interface to the business logic contained in JPOs (considered the implementation layer). These wrappers are also able to hold state across multiple pages of an application and reduce the number of calls to JPOs executing on the backend application server.

There are several approaches to wrapping JPOs: JavaBeans, custom tags, simple Java classes, or JSP includes. ENOVIA recommends the use of JavaBeans as the best solution.

The following topics are discussed:

JavaBeans

JavaBeans are a nice way to encapsulate business logic that might otherwise appear on a JSP.

Our ultimate goal is to keep the bean interface thin and push the business logic all the way back to the application server tier in the form of a JPO. The idea is to have the lightweight bean (living on the Web tier) call on the JPO to do all the work and then hold the resulting information (state) to be served up as needed to JSPs. JavaBeans are simply Java classes that support introspection. They are easy to use within a JSP. The jsp:useBean associates a JavaBean with the JSP and ensures that the object is available for the scope specified in the tag. The bound object can be referenced using the associated id from one or more JSPs (depending on the scope). The tag syntax is as follows:

<jsp:useBean id="name" scope="page|request|session|application" beandetails />

Where beandetails is one of:

class="className"
class="className" type="typeName"
beanName="beanName" type="typeName"
type="typeName"

Returning to our "Hello World" example in the early part of this document, if we assume we have written a HelloWorld bean to act as the interface to our JPO, we might find the following usage on a JSP:

<jsp:useBean id="helloBean" scope="session" class="HelloWorld" />
<html>
<body>
<%
  helloBean.hello();
%>
</body>
</html>

This shows a HelloWorld bean being defined and given an id of "helloBean". The hello() method simply calls on our JPO to generate the "Hello World!" text.

public class HelloWorld implements Serializable
{
  public HelloWorld ()
  {
  }
  public void hello()
  {
  String[] init = new String[] {};
  String[] args = new String[] {};
  // establish a context ? <details not shown>
  int status = JPO.invoke(context, "Hello World", init, "mxMain", args);
  }
}

User/Password Information

The context.getUser() and context.getPassword() methods always give the current user and password, or empty strings if there is none.

For all validate password triggers (check, override, or action), the username, password, and vault are provided as the first, second and third arguments to the trigger program, JPO or Tcl.