490 likes | 651 Views
Angelo Scipione Staff Software Engineer, Sybase Angelo.Scipione@sybase.com August 15-19, 2004. The Enterprise. Unwired. The Enterprise. Unwired. Industry and Cross Platform Solutions. Manage Information. Unwire Information. Unwire People. Adaptive Server Enterprise
E N D
Angelo Scipione Staff Software Engineer, Sybase Angelo.Scipione@sybase.com August 15-19, 2004
The Enterprise. Unwired. Industry and Cross Platform Solutions Manage Information Unwire Information Unwire People • Adaptive Server Enterprise • Adaptive Server Anywhere • Sybase IQ • Dynamic Archive • Dynamic ODS • Replication Server • OpenSwitch • Mirror Activator • PowerDesigner • Connectivity Options • EAServer • Industry Warehouse Studio • Unwired Accelerator • Unwired Orchestrator • Unwired Toolkit • Enterprise Portal • Real Time Data Services • SQL Anywhere Studio • M-Business Anywhere • Pylon Family (Mobile Email) • Mobile Sales • XcelleNet Frontline Solutions • PocketBuilder • PowerBuilder Family • AvantGo Sybase Workspace
Agenda • Recent history of HTML Web DataWindow • HTMLGenerator80, HTMLGenerator90 components • Room for improvement: • Separating DataWindow presentation markup from content • Saving bandwidth • Improving processing • Reducing server processing by offloading work to client • Allowing easy customization of DataWindow generation • TreeView-based editing?… • The XML Web DataWindow! • Designed using more efficient XML-based & Web technologies • DOM XHTML CSS • XML XSLT
Review HTML DataWindow Design Server-Side Client-Side DataStore User request page HTMLGenerator component HTML Page Client-Side Step 1 HTTP get Step 2 Entire DataWindow generation embedded in HTML document sent to client Step 3 HTTP response Step 4 User interacts with DataWindow and entire process repeated JSP Page
HTML Web DataWindow Limitations • DataWindow generated entirely in static HTML on page • Regeneration required on every round-trip to server • Most of this regeneration is duplicate work • Server processing/scalability unnecessarily strained • Bandwidth misspent on unnecessary downloads • Generator is string-buffer-based, limiting extensibility • Customization of generated HTML or CSS not supported • Nested and composite DataWindows not supported
What components are duplicated? • HTML structural layout of DataWindow rendering • CSS style of DataWindow elements as displayed in browser • Almost all client-side JavaScript functionality & control object …basically ALL of the presentation markup, or everything except the DataWindow data content and JavaScript row element objects.
PB 8.0 HTML Web DataWindow HTMLGenerator80 Some related enhancements were introduced, influenced by TeamSybase and customer feedback: • Some bandwidth saved by separating out/caching: • Static client-side JavaScript--including common, date, number, and string functions • Some customization allowed by introducing: • ‘AppendedHTML’ property on text, column, & compute controls
Current (PB 9.0) HTML Web DataWindow HTMLGenerator90 Still regenerating: • Data content • Page layout/design • Presentation/styling (e.g. fonts, colors, borders, etc.) • Some CSS rules in <style> element inside document • Element-specific rules, e.g. absolute positioning, in style attributes of elements • Client-side control in JavaScript inside document …All in single static HTML page, on every round-trip to server
Next Generation Web DataWindow PowerBuilder 10.0 Release Customer feedback for improvement: • Save bandwidth on round-trips to server • Ideally to just DataWindow data • Markup that remains static for the life of the session should only be downloaded once • Reduce server processing and perform more work on the client for improved scalability • Allow more control and convenient way to customize generation
The XML Web DataWindow Solution Utilize latest web technologies: • XHTML • Client-side XML • Client-side XSLT • Standalone CSS stylesheet (with cascaded absolute positioning)
XML Web DataWindow Browsers targeted:
XHTML XHTML is an XML compliant version of HTML • Most popular web vocabulary, leveraging the power of XML • Supported by the vast majority of web browsers • XHTML 1.0 = HTML 4.01 in XML syntax • XHTML 1.0 comprises three document types: • Strict • Transitional • Frameset • XHTML 1.1 introduces superseding document type
Why Use XHTML? Benefits: • Separation of presentation markup from content • Most fundamental principle in web development • Use of XML-specific technologies in architecture • DOM-based generation and parsing • Use of XML-specific tools for customizing • TreeView-based editing
Separating Presentation from Content Within DataWindow: • Content = data values of column, compute, and text controls • Presentation = visual and functional properties of DW controls Benefits of Separating: • Accessibility • Targeted presentation using stylesheets • Improved processing by browser
XHTML Benefits Accessibility United States, Section 508 of the Usability Act • XHTML’s separation of visual elements from actual content make page much more accessible to people with disabilities • XHTML more easily understood by people with visual impairments using screen readers and voice browsers
XHTML Benefits Targeted Presentation • Presentation can now be stored in separate stylesheet documents (CSS and XSL) for XHTML page • Different stylesheets more easily generated for different browsers
XHTML Benefits Improved Processing • Browsers process XHTML documents quicker due to valid, well-formedness rules of XHTML/XML • Copious browser functionality to handle malformed HTML unnecessary • XHTML DTDs prohibit browser-proprietary extensions leading to incompatible browsers
XHTML Benefits Use of XML-specific technologies • W3C Document Object Model (DOM) can be used to implement more robust generation • DOM provides API access to XML “tree” model of objects • Document can be re-traversed during generation • More extensible, e.g. support for nested and composite • User customizations incorporated more easily • DOM-based implementations in XML Web DataWindow: • DataWindow XHTML generator • DataWindow CSS generator • DataWindow XSLT generator Algorithm to separate XHTML presentation from content • DataWindow XML generator
XHTML Benefits Use of XML-specific tools DOM-based TreeView editor can be used to customize XML Web DataWindow at design-time • XHTML Template View introduced in DataWindow Painter • Built on foundation of XML Template View introduced in PowerBuilder 9.0 DOM-based API can be used to customize XML Web DataWindow at runtime • PBDOM in PowerScript
CSS Cascading Style Sheets • Allows style rules to be added to elements of a document, indicating how the content of those elements should be rendered • Helpful tool for separating the contents of an HTML, XHTML, or XML document from its visual presentation • Benefits include faster page download because the stylesheet only needs to be downloaded once and cached • Ideally should contain all style rules (XHTML 1.0 Strict & 1.1+), maximizing separation and minimizing redundancy on every page
CSS in XML Web DataWindow emp_lname_0, birth_date_0, ss_number_0 {background-color:#fffbf0; width:100%;color:#000000;font:8pt "MS Sans Serif", sans-serif;font-style:normal; font-weight:normal;text-decoration:none; text-align:left;border-style:inset;} emp_lname_0 {position:absolute; left:1.349in; top:0.023in; width:1.000in}
Why Use Client-Side XML? Benefits: • Reduces amount of data transferred back and forth between client and server • Increases speed of browsing • No longer have to download a complete HTML page on each request • More responsibility for processing page passed to client • Reduces server-side load; more scalable
Client-Side XML XML Content Determines structural layout XSLT Determines style of elements as displayed in browser XHTML CSS
Client-Side XML • XML data retrieved from server without having to regenerate and download entire DataWindow to browser • JavaScript used to take XML client-side and generate dynamic XHTML content • XML document stored in browser’s memory used as client-side data cache
XSLT Extensible Stylesheet Language Transformations • Provides a way of transforming XML documents into other document formats • For XHTML (which is fundamentally XML), XSLT can be used to transform an XML document into a styled XHTML web page for display in a browser • XSLT goes beyond CSS by allowing rules that change or infuse the content with layout and structure
Why Use Client-Side XSLT? Benefits: • Saves bandwidth • Clients only need to download and cache XSLT code once for DataWindow session • Server processing is reduced with more work being done on client
XML Web DataWindow Design Server-Side Client-Side XML DataStore User request page XSLT XHTML XML Web DW component XHTML Page Client-Side Step 4 Client-side JavaScript uses XSLT to transform XML into XHTML and displays this in the <div> in the browser CSS Step 1 HTTP get Client-side JavaScript Step 2 DataWindow generated in separate XML, XSLT CSS, JS, with transform script sent to client JS control Step 3 HTTP response Step 5 User interacts with DataWindow, but next request only requires download of XML and JS rows JS rows JSP Page
XML Web DataWindow Generator Server-Side 1.) Invoked in the DataWindow engine from server-side code 2.) Generates an XHTML rendering of the DW in a DOM tree 3.) Concurrently generates a CSS stylesheet using a DOM tree with all styling information of the DW’s elements, including absolute positions in cascade 4.) Also generates separate client-side JavaScript files for instantiating the control object and array of row elements • Static client-side set of JavaScript files deployed as usual 5.) Reverse-transforms the XHTML DOM tree to XML and XSLT DOM trees for web publishing • XML = DataWindow data content for the page • XSLT = DataWindow structural layout 6.) Ultimately generates small amount of script to perform explicit transformation on client-side
XML Web DataWindow Client - Demo Client-Side 1.) Downloads source XML file (containing DataWindow content for the page) and XSLT stylesheet, which is cached locally 2.) Performs transformation using XSLT processor 3.) Outputs XHTML result into a <div> section on the page 4.) Downloads, caches, and applies CSS stylesheet for display in the browser 5.) Downloads and caches JavaScript files 6.) Subsequent HTTP Get/HTTP Response only requires regenerating and downloading XML file (and JavaScript row objects file) for updated DataWindow page
XML Web DataWindow Properties For XHTML and XML Web Generation • XHTMLGen.Browser - browser in HTTP header from client • CSSGen.ResourceBase - <link> href attribute value • CSSGen.PublishPath - physical path to publish CSS stylesheet • CSSGen.SessionSpecific - force session-specific CSS, XSLT, JS • JSGen.ResourceBase - <script> src attribute value • JSGen.PublishPath - physical path to publish JavaScript • Data.XHTML - invoke generation and return XHTML • Other properties shared with existing HTML Generation (HTMLGen) properties
XML Web DataWindow Properties For XML Web Generation (additionally) • XSLTGen.ResourceBase - URL referenced by transformation script • XSLTGen.PublishPath - physical path to publish XSLT stylesheet • XMLGen.ResourceBase - URL referenced by transformation script • XMLGen.PublishPath - physical path to publish XML • Data.XMLWeb - invoke generation and return XSLT transform script
DataWindow Painter Properties View - Demo Web Generation tab
DataWindow Painter Properties View - Demo Web Generation tab
DataWindow Painter Properties View - Demo JavaScript Generation tab
HTMLGenerator100 Integration Interface extension • string Generate() - same as before returning HTML • string GenerateXHTML() - invoke generation and return XHTML • string GenerateXMLWeb() - invoke generation and return XSLT transform script
JSP Target Integration DTC Properties dialog
JSP Target Integration DTC Properties Recommendation
When to Use XHTML vs. XML? Or does bandwidth savings compensate for XSLT processing cost? XHTML: • DataWindow rows comprise 1 page • DataWindow rows span multiple pages, but layout inconsistent page-to-page XML (& XSLT): • DataWindow rows span multiple pages, and layout consistent page-to-page Over HTML, both offer: • Accessibility • Resulting markup parsed faster by browser • Ability to customize…
Customizing the Generation At Design-time XHTML Template: • Built upon the DataWindow XML Template framework introduced in PowerBuilder 9.0 • Represents a single-instance document of the resulting DataWindow XHTML <form> element • Only stores the structural layout and any customizations the developer has defined • Applied to the default generation at runtime by setting the Export.XHTML.UseTemplate DataWindow property
XHTML Template Customizations allowed • Style rules of input field elements of the <form> • Overriding default CSS stylesheet property values • Adding or removing CSS stylesheet declarations • Other XHTML element attributes • Overriding attribute values • Removing or adding attributes specific to these elements • JavaScript event handlers • Overriding/redirecting script handlers • Removing or adding event handlers, e.g. beyond the default PowerBuilder DataWindow emulation
Element Context Menus TreeView items offer a context-sensitive pop-up menu for customizing the XHTML Template or element. Presentational and functional specifications: • Style Declarations • Element Attributes • JavaScript Event Handlers
Customizing Style Declarations - Demo Style Declarations Dialog
Customizing Element Attributes Element Attributes Dialog
Customizing JavaScript Event Handlers JavaScript Event Handlers Dialog
DataWindow Painter Properties View - Demo Data Export tab
Unicode/Internationalization • Unicode DBMS-related EAServer patch per CR342484 • Specify UTF-8 encoding for the servlet's response output stream, by including this page directive at the top of the JSP: <%@ page contentType="text/html; charset=UTF-8" %> • Specify UTF-8 encoding for the servlet's request input stream, by calling the following method on the request interface in the JSP, before any calls to request.getParameter(): • request.setCharacterEncoding("UTF8");
And now... ??