11.07.2015 Views

WEB-ENABLE POWERBUILDER APPS WITH SYBASE EASERVER ...

WEB-ENABLE POWERBUILDER APPS WITH SYBASE EASERVER ...

WEB-ENABLE POWERBUILDER APPS WITH SYBASE EASERVER ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

We’ll describe the design and implementation of an XML generationsolution (affectionately referred to here as the PB XML Generator)built using PowerBuilder and Java. The complete solution will beavailable as a free download from the Sybase Developer’s Network(SDN) at www.sybase.com/developer/applicationdeveloper. This downloadwill include:• The full source code for the PowerBuilder and Java components• The full source code for the JSP custom tag library• A Jaguar .jar file with the binaries of each of these (tested on EAServer3.6.1, 4.x)• A sample Web application (also in Jaguar .jar format) demonstratingseveral different XML generation examples from DataWindows thatrun against the standard demo database shipping with EAServer• Installation directions along with Apache Ant deployment scriptsSolution ArchitectureThe PowerBuilder XML Generator enables developers to export existingPB 7.x and 8.x DataWindows as XML through a simple JavaServerPage (JSP) tag library and EAServer components. Figure 1 depicts oursolution architecture. Tag attribute values are specified through a JSP,customizing the DataWindow export to XML. When the JSP containingour tag library is processed, the doStartTag() method of theDataWindowTag class executes. The tag class populates an array ofname-value pairs that map back to the tag library attributes. Theseproperties are then passed to the PBXMLgen/MetaParser component(written in PowerBuilder) where the DataWindow’s metadata isaccessed.It’s here inside the PowerBuilder component thatthe data is retrieved from the database usingdw.retrieve(). The DataWindow metadata, theresult set, and the tag library attributes are thenpassed over to another component written inJava, the PBXMLgen/XMLgenerator. Thiscomponent actually performs the XML generation.The resulting XML is then passedback through the call stack to theoriginal JSP page on its wayback to the requestingclient.The XML producedis compliant with theXML 1.0 specification,meeting all itswell-formedness constraints,and mayoptionally containDataWindow dataand metadata withexplicit markup information,such as columndefinition, aread-only indicator,and syntax. Note: Thecurrent release handlesonly the onewayprocessing of adw.Retrieve() to XML.Building the JSP Custom Tag LibraryWe simply don’t have enough space to adequately describe all theidiosyncrasies of building custom tag libraries. There are a number ofgreat JSP books out there, and most have a chapter or more describinghow to build JSP custom tag libraries. A great reference is Core Servletsand JavaServer Pages by Marty Hall.One of the first challenges we faced in developing the tag library wassharing data between the PowerBuilder and the Java world. In the solutionarchitecture we describe, we have name-value pairs gathered in thetag handler class that need to be passed into the PowerBuilder component.This component reads some of the values it needs, and then mustforward all the name-value pairs to another component written in Java.As you can see, we’re crossing language lines a couple of times.At first we thought we could just use java.util.Properties, but wequickly discovered this was not an option. This class is built atop ahashtable that, unfortunately, PowerBuilder doesn’t understand. Theresult was a BLOB in the method signature of the PowerBuilder proxywhere the java.util.Properties argument was located. To overcome thisproblem we looked to EAServer’s CORBA roots for help.In the CORBA world, interfaces are described using the InterfaceDefinition Language (IDL). Each component deployed to EAServer hasits public interface described in IDL. Jaguar passes around a lot of namevaluepairs, as described by the IDL in Jaguar::Properties. In fact, this IDLrepresentation of name-value pairs is easy to use in PowerBuilder andJava. Through the use of Jaguar::Properties, we were able to seamlesslypass name-value pairs between both languages. Problem solved!Over 95% of the code in the DataWindowTag class merely collects andstores attribute values for use later when the doStartTag() method isinvoked. To achieve this, we declare one private string instance variable foreach attribute. Each attribute requires a setter method (and may actuallyhave a getter method as well), which contains one line of code, for example:public void setLibName(String value) { this.libname = value; }Once the DataWindowTag class has collected all the name-value pairsspecified in the JSP, we move them into an instance of Jaguar::Propertiesto pass them in an intercomponent call. We get a handle to an instanceof the MetaParser object (described in detail in the next section) using aCORBA Factory. Listing 1 describes how to look up a PB component inEAServer from Java.FIGURE 1PB XML Generator Architecturewww.SYS-CON.COM/pbdj/PBDJ volume9 issue47

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!