Switch to standard view 
  Sybase logo
 
 
 



Converting Web Target Pages from Dynamo to JSP

PowerDynamo Web targets are not supported in PowerBuilder 10. This white paper describes how to convert PowerDynamo 4GL and non-4GL Web target pages for inclusion in a JSP Web target.

1 Converting a 4GL Page

You must manually convert every 4GL Page as follows:

ActionDescription
RemoveAll unnamed classes

The following methods:

public void psPage___CreateObjectModel( ) throws Exception {...}
public void psPage___CreateObjectModel( ) throws Exception{...}
public void psPage___InitializeVariables( ) throws Exception {...}
public void psPage___SaveVariables( ) throws Exception {...}
public PSServerPageClass psPage = null;
<%@ include file="/ObjMod90.jsp"%>
InitObjects(dynsession);
Add JAR filejspobject.jar to the target \WEB-INF\lib directory
Add page import statement com.sybase.powerbuilder.jspobject.* to page import:
 <%@page import="com.sybase.powerbuilder.jspobject.*, com.sybase.dynamo.*,.... %>
Add in declaration
class PSServerPageJSPClass extends PSServerPage {
   // controls

   public PSServerPageJSPClass(PageContext context, String pageName, boolean doTrace,
           PSDocumentClass psDocument,PSSessionClass psSession,PSServerClass psServer) {
      super(context, pageName, doTrace,psDocument,psSession, psServer);
      psPage = this;
   }
   public void __CreateObjectModel() {
      showErrorsInAlert = false;
      showErrorsOnPage = false;
      // parameters
      // variables
      // jaguar objects
      // controls
   }
   public void __InitializeVariables() {
      // parameters
      // variables
      // jaguar objects
      // controls
   }
   public void __SaveVariables() {
      // parameters
      // variables
      // jaguar objects
      // controls
   }
   public void __UpdateParameters(){
      // parameters
   }
   public void __UpdateVariables(){
      // variables
   }
   // create web datawindow
   // create 4GL link
} // end of PSServerPageJSPClass
class PSServerPageJSPFactory implements IServerPageFactory {
   public PSServerPage newPage(PageContext context, String pageName, boolean doTrace,
      PSDocumentClass psDocument,PSSessionClass psSession,PSServerClass psServer) {
      return new PSServerPageJSPClass (context, pageName,
         doTrace, psDocument,psSession, psServer);
	}
} // end of PSServerPageJSPFactory
Add script Instance global variable and Run Server Event Model

PSDocumentClass psDocument = new PSDocumentClass(request, response, out, application);
PSSessionClass psSession;
psSession = new PSSessionClass(session);
PSServerClass psServer = new PSServerClass(psDocument);
PSServerPageJSPFactory psPageFactory = new PSServerPageJSPFactory();
PSServerPageJSPClass psPage = (PSServerPageJSPClass)PSServerPageJSPClass.getPage(
   pageContext, psPageFactory, "test_4gl.jsp", false, psDocument,psSession, psServer);

if (!psPage.runServerEventModel()) return;
Change Add the psPage prefix to all control variables. For example:

cb_1.visible -> psPage.cb_1.visible
st_1.value   -> psPage.st_1.value
Uppercase to lowercase for some functions, adding parameters where necessary:

psPage.GenerateBodyPrologue()  -> psPage.generateBodyPrologue(out)
psPage.GenerateBodyEpilogue ()  -> psPage.generateBodyEpilogue(out)
psPage.EndOfPage() -> psPage.endOfPage()

1.1 Controls

1.1.1 Declare control variables

Each control should be declared as a member variable of the PSServerPageJSPClass. For example:

class PSServerPageJSPClass extends PSServerPage {
	// controls
	PSButtonClass cb_1;
...
}

1.1.2 Create control variables

Create each control variable in the __CreateObjectModel function, where n equals the total number of control variables that you are creating. For example:

public void __CreateObjectModel() {
	// controls
	_controls = new IControl[n];
	_controls[0] = new PSButtonClass(this, "cb_1", "Button1");
	}

1.1.3 Initialize control variables

Initialize each control variable in the __InitializeVariables function. For example:

public void  __InitializeVariables () {
	// controls
	cb_1 = (PSButtonClass)_controls[0]; // cb_1
	cb_1.initComVariable(psDocument,psSession, psServer);
}

1.1.4 Control list

Use the following classes to declare, create, and initialize controls:

ControlClass
ButtonPSButtonClass
CheckBoxPSCheckBoxClass
LinkPSLinkClass
ListBoxPSDropDownListClass
ImagePSImageClass
Radio ButtonPSRadioGroupClass
TextAreaPSTextAreaClass
Single line TextPSTextClass
Static TextPSStaticTextClass

1.2 Parameters

1.2.1 Declare parameters

Each parameter must be declared as a global variable in the JSP Page. For example:

<!%
// parameters
public String p1;
%>

1.2.2 Create parameters

Create each parameter in the __CreateObjectModel function, where n equals the total number of parameters you are creating:

public void __CreateObjectModel() {
	// parameters
	_parameters = new IPageGeneration[n];
	_parameters[0] = new PSPageParameterClass(this, "p1", "param1");
}

1.2.3 Initialize parameters

Initialize each parameter in the __InitializeVariables function:

public void  __InitializeVariables () {
	// parameters
	p1 = ((PSPageParameterClass)_parameters[0]).initialize(this); // p1
}

1.2.4 Update parameters

Update each parameter in the __UpdateParameters function:

public void __UpdateParameters(){
	// parameters
	((PSPageParameterClass)_parameters[0]).setValue(p1); // p1
	}

1.3 Page Variables

1.3.1 Declare page variables

Each page variable should be declared as a global variable in the JSP Page. For example:

<!%
// parameters
public String p1;
%>

1.3.2 Create page variables

Create each page variable in the __CreateObjectModel function, where n equals the total number of page variables you want to create:

public void __CreateObjectModel() {
// variables
   _variables = new IPageGeneration[n];
   _variables[0] = new PSIntPageVariable(this, "v1", LIFETIME.SESSION, PSPageVariableClass.CLIENT_NONE, 0, "v1s");
}

1.3.3 Initialize page variables

Initialize each page variable in the __InitializeVariables function:

public void  __InitializeVariables () {
	// variables
	v1 = ((PSIntPageVariable)_variables[0]).initialize(this); // v1
}

1.3.4 Update page variables

Update each page variable in the __UpdateVariables function:

public void __UpdateVariables (){
	// variables
	((PSIntPageVariable)_variables[0]).setVarValue(v1); // v1
}

1.3.5 Page Variable List

Use the following classes to declare, create, initialize, and update page variables:

Variable TypeVariable Class
booleanPSBooleanPageVariable.
bytePSBytePageVariable
charPSCharPageVariable
doublePSDoublePageVariable
floatPSFloatPageVariable
intPSIntPageVariable
longPSLongPageVariable
shortPSShortPageVariable

1.4 DataWindow Page

You must manually convert scripts for instantiating a DataWindow on a 4GL Web page as follows:

ActionDescription
Change

Change dw_1__Create in PSServerPageJSPClass to be a member function:

// Create Web DataWindow
public PSWebDataWindowClass dw_1__Create(String name){
   PSJaguarConnection jagConn = new PSJaguarConnection("Hostname",
      "DataWindow/HTMLGenerator100", false);
   PSDataWindowSourceClass dwSource = new PSDataWindowSourceClass(
      "PBL File", "dw_department", false);
   PSConnectionParmsClass dbConn = new
      PSConnectionParmsClass("EAS_Demo_DB_V10", true);
   PSWebDataWindowClass webDW = new PSWebDataWindowClass(
      this, name, false, jagConn, dwSource, dbConn, 0);
   webDW.bAutomaticRetrieve = true;
   return webDW;
}
Add

Create Web DataWindow in the __CreateObjectModel function. For example:

_controls[n] = dw_1__Create("dw_1");

Initialize WebDataWindow Class in __InitializeVariables function. For example:

dw_1 = ((PSWebDataWindowClass)_controls[n]).initialize(this); // dw_1
dw_1.initComVariable(psDocument,psSession, psServer);

1.5 Server-side scripts

Server-side scripts defined for any control object must be modified to use Java rather than DynaScript or JavaScript. Extended classes should be created for controls containing server-side scripts.

1.5.1 Define a new control class

Create a new class that extends the original control class. Implement the server-side event in the new class. For example, a button class has server-side script in its ServerAction event.

class cb_1_class extends PSButtonClass {
   PSServerPageJSPClass psPage;
   public cb_1_class(IPageHost host, String name, String initialValue) {
      super(host, name, initialValue);
      psPage = (PSServerPageJSPClass)host;
   }
   public void ServerAction() { // {{ EVENT("cb_1","ServerAction")
      psDocument.WriteLn("Button action");
   } // }}
} // end of cb_1_Class

1.5.2 Use the new control class

Use the new control class to declare and instantiate the control variable. You can also use the new control class to do type casting:

cb_1 = (cb_1_class)_controls[0]; // cb_1

1.6 4GL Page Sample

<%@ page import="com.sybase.powerbuilder.jspobject.*" %>
<%!
// variable declarations
// parameters
public String p1;
// page variables
public int v1;
// jaguar objects
// parameters
// jaguar objects
// controls
class cb_1_class extends PSButtonClass {
   PSServerPageJSPClass psPage;
   public cb_1_class(IPageHost host, String name, String initialValue) {
      super(host, name, initialValue);
      psPage = (PSServerPageJSPClass)host;
   }
   public void ServerAction() { // {{ EVENT("cb_1","ServerAction")
      psDocument.WriteLn("Button action");
   } // }}
} // end of cb_1_Class

// PSServerPage Version 10.0
class PSServerPageJSPClass extends PSServerPage {
   // controls
   PSButtonClass cb_1;
   PSStaticTextClass st_1;
   PSLinkClass A1;
   PSWebDataWindowClass dw_1;
   PSServerPageJSPClass psPage;

   public PSServerPageJSPClass(PageContext context, String pageName, boolean doTrace,
         PSDocumentClass psDocument,PSSessionClass psSession,PSServerClass psServer) {
      super(context, pageName, doTrace,psDocument,psSession, psServer);
      psPage = this;
   }
   public void __CreateObjectModel() {
      showErrorsInAlert = false;
      showErrorsOnPage = false;
      // parameters
      _parameters = new IPageGeneration[1];
      _parameters[0] = new PSPageParameterClass(this, "p1", "param1");
      // variables
      _variables = new IPageGeneration[1];
      _variables[0] = new PSIntPageVariable(this, "v1", LIFETIME.SESSION,
         PSPageVariableClass.CLIENT_NONE, 0, "v1s");
      // jaguar objects
      // controls
      _controls = new IControl[4];
      _controls[0] = new cb_1_class(this, "cb_1", "Button1");
      _controls[1] = new PSStaticTextClass(this, "st_1", "Static text");
      _controls[2] = A1__Create("A1");
      _controls[3] = dw_1__Create("dw_1");
   }
   public void __InitializeVariables() {
      // parameters
      p1 = ((PSPageParameterClass)_parameters[0]).initialize(this); // p1
      // variables
      v1 = ((PSIntPageVariable)_variables[0]).initialize(this); // v1
      // jaguar objects
      // controls
      cb_1 = (cb_1_class)_controls[0]; // cb_1
      cb_1.initComVariable(psDocument,psSession, psServer);
      st_1 = (PSStaticTextClass)_controls[1]; // st_1
      st_1.initComVariable(psDocument,psSession, psServer);
      A1 = (PSLinkClass)_controls[2]; // A1
      A1.initComVariable(psDocument,psSession, psServer);
      dw_1 = ((PSWebDataWindowClass)_controls[3]).initialize(this); // dw_1
      dw_1.initComVariable(psDocument,psSession, psServer);
   }
   public void __SaveVariables() {
      // parameters
      // variables
      _variables[0].save(); // v1
      // jaguar objects
      // controls
   }
   public void __UpdateParameters(){
      // parameters
      ((PSPageParameterClass)_parameters[0]).setValue(p1); // p1
   }
   public void __UpdateVariables(){
      // variables
      ((PSIntPageVariable)_variables[0]).setVarValue(v1); // v1
   }
   // create web datawindow
   public PSWebDataWindowClass dw_1__Create(String name){
      PSJaguarConnection jagConn = new PSJaguarConnection
         ("Hostname", "DataWindow/HTMLGenerator100", false);
      PSDataWindowSourceClass dwSource = new PSDataWindowSourceClass
         ("PBL file", "dw_department", false);
      PSConnectionParmsClass dbConn = new PSConnectionParmsClass
         ("EAS_Demo_DB_V10", true);
      PSWebDataWindowClass webDW = new PSWebDataWindowClass
         (this, name, false, jagConn, dwSource, dbConn, 0);
      webDW.bAutomaticRetrieve = true;
      return webDW;
   } // create dw_1
   // create 4GL link
   public PSLinkClass A1__Create(String name){
      PSLinkClass linkObj = new PSLinkClass(this, name, "http:\\XXX");
      return linkObj;
   }
} // end of PSServerPageJSPClass

class PSServerPageJSPFactory implements IServerPageFactory {
   public PSServerPage newPage(PageContext context, String pageName, boolean doTrace,
         PSDocumentClass psDocument,PSSessionClass psSession,PSServerClass psServer) {
      return new PSServerPageJSPClass (context, pageName, doTrace,
         psDocument,psSession, psServer);
   }
} // end of PSServerPageJSPFactory
%><%
PSDocumentClass psDocument = new PSDocumentClass(request, response, out, application);
PSSessionClass psSession;
psSession = new PSSessionClass(session);
PSServerClass psServer = new PSServerClass(psDocument);
PSServerPageJSPFactory psPageFactory = new PSServerPageJSPFactory();
PSServerPageJSPClass psPage = (PSServerPageJSPClass)PSServerPageJSPClass.getPage
   (pageContext, psPageFactory, "test_4gl.jsp", false, psDocument,psSession, psServer);

if (!psPage.runServerEventModel()) return;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
    <META HTTP-EQUIV="PowerSiteData" NAME="SERVERLANGUAGE" CONTENT="Java">
    <TITLE>test_4gl</TITLE>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <META content="PB10.0.0.5035" name="GENERATOR">
</HEAD>
<BODY bgColor="white" OnLoad="psPage.OnLoad();">
   <% psPage.generateBodyPrologue(out); %>
<P>
<% if (psPage.cb_1.visible) { %><INPUT language="JavaScript" id="INPUT1"
   type="button" value="<%= psPage.cb_1.getValueAsString() %>"
   name="cb_1" <%= psPage.cb_1.getDisabledAttribute() %>
   OnClick=" psPage.ButtonPress(this.name);"><% } /* endif */ %>
</P>
<P>
<% if (psPage.st_1.visible) { %><SPAN id="OBJECT1">
<%= psPage.st_1.value %></SPAN><% } /* endif */ %>
</P>
<P>
<% if (psPage.A1.visible) { %><A id="A1"
   href="<%= psPage.A1.GetHREFAttribute() %>"
   target="_blank">Link</A><% } /* endif */ %>
</P>
<A id="A2" name="NAME1">test <P> <% if (psPage.dw_1.visible) { %>
<%
psPage.dw_1.Generate();
%>
<% } /* endif */ %></P></A>
<% psPage.generateBodyEpilogue(out); %>
</BODY>
</HTML>
<% psPage.endOfPage(); %>

2 Converting a Non-4GL Page

You must manually convert every non-4GL Page as follows:

ActionDescription
RemoveAll unnamed classes
All /*TRANSLATOR_COMMENT: Unknown type of....*/
<%@ include file="/ObjMod90.jsp"%>
InitObjects(dynsession);
Add JAR filejspobject.jar to the target \WEB-INF\lib directory
Add page import statement

com.sybase.powerbuilder.jspobject.* to page import:

<%@page import="com.sybase.powerbuilder.jspobject.*, com.sybase.dynamo.*,... %>
Add script
<%
// global instance for the page
PSDocumentClass psDocument = new PSDocumentClass(request, response, out, application);
PSSessionClass psSession = new PSSessionClass(session);
PSServerClass psServer = new PSServerClass(psDocument);
%>

2.1 DataWindow Page

You must manually convert scripts for instantiating a DataWindow on a non-4GL Web page as follows:

ActionDescription
Remove declaration
Public PSJaguarConnention jagConn = null;
Public PSConnectionParmsClass dbConn = null;
Public UnnamedClassXXX webDW = new UnnamedClassXXX();
Change script

Change relative script as follows:

<%
{
   PSJaguarConnection jagConn = new PSJaguarConnection
      ("Hostname ","DataWindow/HTMLGenerator100", false);
   PSDataWindowSourceClass dwSource = new PSDataWindowSourceClass
      ("PBL File ", "dw_department", false);
   PSConnectionParmsClass dbConn = new
   PSConnectionParmsClass("EAS_Demo_DB_V10", true);
   PSDataWindowClass webDW = new PSDataWindowClass(pageContext, request,
      "webDW_1", false, jagConn, dwSource, dbConn, 0);

   webDW.Generate();
}
%>

2.2 Non-4GL Page Sample

<%@ page import="com.sybase.powerbuilder.jspobject.*" %>
<%
// global instance for the page
PSDocumentClass psDocument = new PSDocumentClass(request, response, out, application);
PSSessionClass psSession = new PSSessionClass(session);
PSServerClass psServer = new PSServerClass(psDocument);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
    <META HTTP-EQUIV="PowerSiteData" NAME="SERVERLANGUAGE" CONTENT="Java">
    <TITLE>test</TITLE>
</HEAD>
<BODY bgColor="white" PSPARAMS="">
<P>Put your data here </P>
<FORM method="post">
    <P><INPUT id="INPUT1" type="submit" value="Button" name="cb_1"></P>
</FORM>

<%
{
   PSJaguarConnection jagConn = new PSJaguarConnection
      ("HostName", "DataWindow/HTMLGenerator100", false);
   PSDataWindowSourceClass dwSource = new PSDataWindowSourceClass
      ("PBL File", "dw_department", false);
   PSConnectionParmsClass dbConn = new PSConnectionParmsClass
      ("EAS_Demo_DB_V10", true);
   PSDataWindowClass webDW = new PSDataWindowClass(pageContext, request,
      "webDW_1", false, jagConn, dwSource, dbConn, 0);

   webDW.Generate();
}
%>

</BODY>
</HTML>


Back to Top
© Copyright 2010, Sybase Inc.