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.

Attribute nameDescriptionlibNameFull path of the .pbl/.pbd library or the EAServer package/component name where the DataWindow can be found, requireddwNameDataWindow name, requireddbmsDataSource, ex: "ODBC", requireddbparmDatabase parameters, ex:"UseContextObject='No',ConnectString='DSN=EAS Demo DBV3;UID=dba;PWD=sql'", requiredserverinfoEAServer location, defaults to "iiop://localhost:9000"logidEAServer Login ID, defaults to "jagadmin"logpass EAServer Login password, defaults to ""rootElementXML root element tag, defaults to "Root"rowElementXML row element tag, defaults to "Row"colNameA comma-separated list of existing and new column names,ex: "f_name -> first_name, l_name -> last_name" (a spacemust be included on either side of the "->"), if left empty, theDataWindow column names are usedretrievalArgDataWindow retrieval arguments to be specified as a commaseparatedlist (no spaces), ex: "100,Whitney". Maximum 20entries, defaults to no argumentsxmltoFileThe XML generated will also be saved to the path/file specifiedomitXMLdecl Whether or not to omit the XML declaration (set to true toomit the declaration if you wish to append multiple XMLdocuments), defaults to "false"dwcDataDynamically inserts "CDATA" if special characters preventingthe proper display of XML are detected, defaults to "true"dwmetaData When set to true, the metadata is included in the XML,defaults to "false"processGroup Group processing (not yet implemented)nestedRetrieve Nested DataWindow processing (not yet implemented)appDebugOutput debugging information in the JSP and set thecomponent trace, debug, pb.debug and pb.trace repository,option to true in EAServer for the PBXMLgen package onlyTABLE 1Custom tag attributes for the DataWindowTag classOnce we have a Factory from our doCorbaLookup() method, we needto do one more thing before we have an invocable component reference:…PBXMLgen.MetaParser parser;Factory factory = doCorbaLookup("PBXMLgen", "MetaParser");If( factory != null) {parser = PBXMLgen.MetaParserHelper.narrow(factory.create());} else {//log the error out using the JSPWriter}…The colName attribute contains a list of DataWindow column namesand what they should map to in the generated XML. For simplicity, thissingle attribute is expanded into two string arrays, dwnames and newnames.Through the of_parse_meta() method, we pass in the namearrays, the name-value pairs, and a StringHolder that will contain thegenerated XML. Intercomponent calls that need to leverage pass-by-referencearguments must use holder classes. When this method callreturns, the StringHolder argument contains the generated XML, whichis then written out using the JSPWriter’s print() method.…String xml = "";StringHolder xml_holder = new StringHolder( xml);//tagprops is an instance of Jaguar::Properties//dwnames and newnames are String arraysint rtn = parser.of_parse_meta(dwnames, newnames, tagprops,xml_holder);…In our implementation, a number of customizable attributes can beused to control how the XML is generated from the DataWindow. In a JSPcustom tag library, it’s the responsibility of the taglib.tld file to defineeach of the attributes on the tag. Table 1 is a list and description of eachattribute we defined for the DataWindowTag class.Mining for Metadata: The PB ComponentWhen building the PB XML Generator we wanted to leverage corePowerBuilder functionality. To that end, we extracted the metadata from theDataWindow using the dw.describe() method and retrieved the data usingthe standard dw.retrieve() method. This is significantly simpler to implementthan working with Statements (or PreparedStatements) in Java. Most of thecode inside the of_parse_meta()method is straightforward PowerScript, likeinitializing SQLCA to connect to the database and creating and initializing aDataStore with the values passed in from the custom tag attributes.One area of interest is how the method accesses the DataWindow object.The custom tag library provides two different options, either an absolute pathto a .PBL or .PBD or the name of a package/component. Both approachesleverage PowerBuilder’s ability to dynamical modify the library list throughthe setLibraryList() method; however, determining what the libraries arewhen a package/component is specified deserves an explanation. When youdeploy a PowerBuilder component to EAServer, typically all the objects arebundled in one or more .PBD files and copied over to the EAServer repository.We need to use three pertinent properties and one method call to assembleabsolute paths from the given package/component:• com.sybase.jaguar.component.type• Jaguar/Management API’s getEnv() method• com.sybase.jaguar.component.pb.cookie• com.sybase.jaguar.component.pb.librarylistThe first property (.type) is a check to make sure the named package/componentis indeed a PB component. It doesn’t make sense lookingfor a DataWindow if the component is an EJB! Next, PowerBuilderuses a strict naming convention to track deployments – “Cxx”, where “C”is a constant and xx is a sequential number, for example, C23 and C134are valid directory names. Each of these directories would contain all the.PBDs for a given component. The .pb.cookie property tracks the current“version” number. Inside any EAServer repository each PowerBuildercomponent would have a directory structure similar to this:$JAGUAR/repository/component///CxxTo determine what $JAGUAR equates to, we used the Jaguar/Management API’s getEnv() method, useful for looking up environmentvariables. The .pb.librarylist property contains a delimited list oflibraries, and it uses a $ prefix to indicate a relative path to each librarybased on the aforementioned cookie structure. With this knowledge,translating a package/component becomes an exercise in string manipulation,yielding an absolute path for each library. This information ispassed into the setLibraryList method.At this point, we can access any of the objects in these newly discovered.PBDs, including the DataWindow object that was specified as a taglibrary attribute. We retrieve the data from the database, extract themetadata from the DataWindow, and store it in a simple structure.PowerBuilder structures map seamlessly into CORBA IDL structures,allowing them to easily be passed into Java components. And the reverseis true as well. After running the proxy project, the Jaguar::Properties IDLstructure is represented as a structure in PowerBuilder. All this informationis passed into the Java component where final assembly of the XMLdocument will take place.8 PBDJ volume9 issue4 www.SYS-CON.COM/pbdj/

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

Saved successfully!

Ooh no, something went wrong!