YOUR FEEDBACK
Verizon Becomes a Counter-Android Linux Convert
JNels wrote: Hey - Jeffrey Nelson here at Verizon Wireless. Not a bit of ...
SOA World Conference
Virtualization Conference
$200 Savings Expire May 16, 2008... – Register Today!


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
POWERBUILDER LINKS YOU MUST CLICK ON


Resolving PSR Compatibility Issues

Digg This!

The current PSR compatibility issues between PowerBuilder and the PowerJ Java DataWindow can be resolved using PowerScript and Java source to pass a DataWindow object's FullState, bringing your PowerBuilder reporting applications into the Java realm.

A Powersoft Report (PSR) is a data file that represents a snapshot of a DataWindow or DataStore, including data and presentation information. This mechanism allows the PowerJ or PowerBuilder developer to save the current state of a DataWindow or DataStore for reporting purposes. Through PowerBuilder and PowerJ a PSR can be viewed, printed, and manipulated; however, it can't make updates back to its data source. PSRs can be created within PowerBuilder, InfoMaker, DataWindow Builder, and Java DataWindow. Ideally, you can save a PSR in one of the products mentioned above and load it into another for viewing or printing at a later time. Currently, a conflict in storage formats prevents the use of PowerBuilder-generated PSRs within the Java DataWindow.

Introducing the Java DataWindow
The Java DataWindow is shipped with the PowerJ Java IDE. A 100% Java-implemented port of the PowerBuilder DataWindow control, it contains all the functionality of the original DataWindow with the exception of RichText, OLE, and Graph presentation styles. The DataStore, a nonvisual representation of the DataWindow, is also implemented within the Java DataWindow source code. It's a useful tool for Java development in nonvisual code such as Enterprise JavaBeans (EJBs). There are two versions of the Java DataWindow to support both AWT and Swing client-side architectures. With the introduction of the Java DataWindow, it's possible to bring DataWindow objects and PSRs to Java applets, applications, servlets, EJBs, and JavaServer Pages (JSPs).

Compatibility Issue
The PowerBuilder, InfoMaker, and DataWindow Builder codelines have changed with regard to PSR creation. Previously, PSRs were stored with an internal format that involved storage BLOBs. This storage format quickly exhausted memory when saving larger PSR reports. This overhead was resolved by introducing a standard OLE format save; however, the Java DataWindow wasn't designed to handle this format. When loading a PSR stored in the OLE storage format into the Java DataWindow, the following exception is seen in the Java console:

PBStorage Error: load: unable to load, file is in OLE storage format
DWObject Error: load: error loading PSR file c:\pbpsr.psr

The storage format change was made in the following PowerBuilder, Infomaker, and DataWindow Builder builds:

  • 6.5 build 1197
  • 7.0.2 build 8038
  • 8.0 build 1299
Enabling the Java DataWindow to load PSRs saved in the OLE storage format can be done only by calling OLE-related DLLs. The Java DataWindow is a 100% Java implementation and calling such DLLs would make it platform-dependent, not 100% Java implemented. Allowing the user to save a PSR with the original storage format is being considered in future builds of PowerBuilder, InfoMaker, and DataWindow Builder. This enhancement request has been sent to the PowerBuilder development staff under change request number 267522 and is expected no earlier than the PowerBuilder 9.0 codeline. The progress of this enhancement can be monitored by accessing http://info.sybase.com/CGI-BIN/OM_ISAPI.DLL? clientID=172206&softpage=Solved_Cases using a search of "267522".

Workaround
In the meantime, there's a workaround that will save a snapshot of your DataWindow or DataStore within PowerBuilder that can be loaded into the Java DataWindow and vice versa. The FullState property of the DataWindow object contains its entire state, including the DataWindow object specification, data buffers, and status flags. Using the GetFullState method of either the PowerBuilder or Java implementation stores the FullState into a BLOB or byte array. The FullState of a DataWindow object can then be written to a file using simple Java or PowerScript code. Although similar to creating a PSR, additional information (e.g., data buffers and status flags) is included.

Testing has shown that including this information in the FullState can result in data up to 10% bigger than a PSR. Although there's some overhead in this workaround, having access to the data buffers and status flags allows changes to be updated to the database. The ability to perform database updates is an advantage unavailable to PSR file use.

The following is the source to write out the current FullState of a PowerBuilder DataWindow or DataStore to a file in PowerScript:

integer iFileNum
Blob blob_data
dw_1.GetFullState(blob_data)
iFileNum = FileOpen("c:\\mydwblob.bin", &
StreamMode!, Write!, LockWrite!, Replace!)
FileWrite(iFileNum, blob_data)
FileClose(iFileNum)

and to write out the current FullState of a Java DataWindow or DataStore to a file in Java:

try {
String _psrFile = "c:\\mydwblob.bin";
byte[][] b = new byte[1][];
dw_1.getFullState( b );
// b[0] contains the fullstate at this point
java.io.FileOutputStream fstream =
new java.io.FileOutputStream( _psrFile );
java.io.DataOutputStream dataout =
new java.io.DataOutputStream( fstream );
dataout.write( b[0], 0 , b[0].length );
dataout.close();
} catch ( Exception e ) {

The data file created in either sample can now be loaded into any PowerBuilder or Java process. The BLOB needs to be read from the data file and then added to the DataWindow object using the SetFullState method. Once the FullState has been applied to the DataWindow object, the data can be viewed, printed, and manipulated. Updates can also performed if the DataWindow object is pointing to the correct data source.

To read in the FullState of any DataWindow or DataStore from a file in PowerScript, use the following code:

integer iFileNum
Blob blob_data
iFileNum = FileOpen("c:\\mydwblob.bin", &
StreamMode!, Read!)
FileRead(iFileNum, blob_data)
FileClose(iFileNum)
dw_1.SetFullState(blob_data)

Use the code in Listing 1 to read in the FullState of any DataWindow or DataStore from a file in PowerJ.

These code samples involve file I\O to save and load the FullState of a DataWindow. For security reasons the use of file I\O is restricted within normal applet scenarios. Necessary precautions must be taken when using this source within the context of an applet. This is commonly resolved by signing the applet for file I\O privileges.

An Application of the Workaround
Expanding on this idea, the DataStore object can be used within the context of a JSP to load a data file containing a DataWindow FullState. Once the FullState has been applied, methods to view or manipulate the DataStore can be invoked. A JSP is a Java architecture designed to create dynamic HTML responses based on Java source. The Java source (found between the <% %> braces in a JSP) is compiled by a J2EE-compliant application server each time the JSP is requested. Once the JSP is compiled, the application server returns the generated HTML back to the client. In the sample JSP (see Listing 2) the HTML equivalent of the DataWindow object's data and presentation (stored in the DataWindow.Data.HTML DataWindow object property) is output using the DataWindow's describe method. The Java DataWindow classes are stored in the DataWindow.jar file provided with PowerJ. A J2EE-enabled application server, such as the Sybase EAServer, requires the DataWindow.jar to be added to its Java classpaths before this JSP file can be compiled. Consult your application server's documentation for instructions on the proper deployment of JSPs.

Conclusion
Resolving this compatibility issue with the proposed workaround will allow you to share the responsibility of DataWindow reporting between PowerBuilder and the Java DataWindow provided with PowerJ. As J2EE Web applications take a stronger foothold in the technology marketplace, the ability to bring PowerBuilder-generated reports to J2EE Web applications is a powerful asset to the PowerBuilder developer interested in flirting with Java programming.

About Tim McConnell
Tim McConnell is a senior product support consultant for the enterprise solutions division of Sybase, Inc., in Waterloo, Ontario. He focuses primarily on the Sybase PowerJ and EAServer products.

PBDJ LATEST STORIES . . .
3rd International Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
The PB Future: More on Graphs in PowerBuilder 11.5
Last week I posted a screen shot of the new 3D Rendering capabilities being added to some of the 3D graphs in PowerBuilder 11.5. It was met with mixed reviews on the PowerBuilder Futures newsgroup (forums.sybase.com) so I went back to the drawing board to see what I could come up with.
BluePhoenix Expands Modernization Collaboration with Microsoft
BluePhoenix announced that it has expanded its collaboration with Microsoft on legacy modernization projects. The collaboration provides customers moving their applications or databases to .NET-based environments the best in both modernization services and technical support. BluePhoeni
Sybase PowerBuilder Delivers AJAX and .NET Enhancements Enabling Rich Internet Application Development
Sybase announced that AJAX development capabilities and further Microsoft .NET enhancements have been added to the latest version of Sybase PowerBuilder 11, the premier 4GL rapid application development (RAD) tool. PowerBuilder 11.2 represents another milestone in the PowerBuilder road
PowerBuilder 11.2 Released: Sybase's Flagship IDE
Sybase has released the production version of its flagship .NET development tool - PowerBuilder version 11.2. This latest release of its premier IDE for RAD includes not only standard fixes but also a good list of new features. Here is the 'Coles Notes' version of these new features.
PowerBuilder Takes You To .NET
In June of 2007, Sybase released PowerBuilder 11. PowerBuilder developers can now deploy PowerBuilder components as .NET Assemblies or as .NET Web Services. A PowerBuilder developer can now create these .NET resources so that those who develop .NET solutions can benefit from PowerBuild
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE
BREAKING POWERBUILDER / SYBASE NEWS
Sybase and Sun Set Guinness World Record for World's Largest Data Warehouse
Sybase, Inc. (NYSE:SY), the largest enterprise software and services company exclusively