PowerBuilder to Java JSF Online Presentation


Demo presentation text:

Hello!

In this Demo we will show you how to automatically migrate PowerBuilder to Java with JSF.

First of all, we will show how our demo application in PowerBuilder works before the migration. Our application is a book store, there are two datawindows. There is description of the chosen book in the upper datawindow, and in the second datawindow the list of stores is available. Also there are some options. For example, you can add a book or a store in pop-up windows. And you can delete them.

So, it is a very simple application that will perfectly meet our demo requirements.

Now let’s start the migration. First, we should launch Ispirer Migration Commander. This is the most powerful tool to migrate code from one language to another. At the left side we need to open source files. You can see PowerBuilder project here. Also we need to open target folder for conversion results. Then we need to choose “Options” and select “Migration”. In the dialog window, we need to choose the path to the ini file with information about migration options.Our file contains the following information: UI_TYPE=JSF. Once all these steps have been completed, we need to specify our source – PowerBuilder – and our target –Java. Then we select all files for conversion and we need to press the “Run” or F5 to start the conversion. The migration process can take some minutes. You can see the log of conversion at the bottom of the screen. Once the migration is done, we can find target project files at the right side of the tool.

So, let’s look at sra migration. In our source project we have a demo application file. For this file, we create a java class. If sra file has an open event, it means that we need to create a public void method inside this java class:

AppOpenEvent() { open();}

public void open(){}

If sra file contains general variables, which are global for the whole application it means that we need to declare the same variables of corresponding type and make them public and static.

Let’s move on to srw files. First, we need to create a java class with the same name as the window name. This class should contain a simple constructor. If srw file has an open event it means the same as for sra file. (We need to create a public void method, and this method should be included into the constructor of this class:

public Main_w() {open();}

public void open(){} )

But the main part of this demo migration is conversion of controls. For almost every powerbuilder control it is necessary to divide conversion code into ui and logic parts. In addition, when a control is converted as the logic part, we need to create two java classes for both windows: where control is located and for control itself.

One more common thing for all controls is that all of them are declared and initiated as singleton, so their describing classes contain this pattern realization.

Let’s look at the first control. For example, it is cb_cancel commanbutton control.

Declaration of this control in forward block in the source goes to java class which corresponds to window where control is placed and looks like Commandbutton cb_cancel;

I’d like to underline that Commandbutton is the interface for this control, and cb_cancel correspomds to the control name from the source.

Then we need to migrate the control creation which is described in create block. In the same java class, the initialization of this control will be placed into the class constructor. It looks like:

public W_main() {

cb_cancel = Cb_cancel.getInstance();

}

Let’s move on. Now we can see a java class which corresponds to the control itself. It looks like this:

public class Cb_cancel implements Commandbutton {

public static Cb_cancel instance = null;

public static Cb_cancel getInstance() {

if (instance == null) {

instance = new Cb_cancel();

}

return instance;

}

@Override

public void clicked() {

}

}

This class corresponds to the control and should implement corresponding interface, also it should contain the realization of all the necessary methods, which go after the control description in the source, in this case this method is “clicked”.

As for the ui migration, we need to create the following tag with corresponding properties:

As for other controls we have similar migration process but the difference is that they may have other fields or methods.

In addition, PowerBuilder has specific sql statements. For example, we have such thing as cursor for sql queries. In the source, it looks like this:

DECLARE book_list_cursor CURSOR FOR

SELECT title

FROM powerbuilderdemo_book;

Go to java classes and open corresponding file in target folder (W_store_add.java). After migration is done, we should get the following code:

try(ResultSet book_list_cursor = GlobalVariable.SQLCA.getConnection().prepareStatement("SELECT title FROM powerbuilderdemo_book").executeQuery();){

boolean FetchStatus = false;

book_list_cursor.setString(1,title);

while(true){…}

} catch(SQLException se) {

se.printStackTrace();

}

So, we need to declare variable with ResultSet type, its name is the same as cursor name. In try/catch block we need to initialize this variable. GlobalVariable is a java class with global variables and one of them is SQLCA; getConnection() is a method for SQLCA to get connection; input parameter is created as select query in cursor declaration (SOURCE: SELECT title FROM powerbuilderdemo_book) and it is double-quoted.

Let’s see how our application works after the migration. The java application looks similar to the source PB application. We can find here two tables with information about books and stores. We can also add or delete a book or a 01:16 store. The only difference is that for these actions new windows (pages) open, but it is possible to use another option to make them pop-up window.

This is how our tool can proceed with PBscripts. Hope this Demo was useful. Feel free to contact us for more information about our conversion tools and services. Thank you for your attention!

Do you want to move from PowerBuilder to Java?

Let's do it together!

Learn more