Skip to main content link. Accesskey S
  • Log In
  • Help
  • IBM Logo
  • IBM Forms wiki
  • All Wikis
  • All Forums
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • IBM Redbooks
Community Articles Product Documentation Learning Center IBM Redbooks This category All IBM Forms 4.0 documentation IBM Forms Server 4.0 API documentation Custom Search Scope...
Search
Community Articles > Samples > XForms Samples > IBM Forms 4.0 HTML Extensions and YUI3 charts
  • New Article
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

cees van der woude
Contribution Summary:
  • Articles authored: 1
  • Articles edited: 1
  • Comments Posted: 0

Recent articles by this author

IBM Forms 4.0 HTML Extensions and YUI3 charts

IBM 4.0 provides new hooks to add new functionality to your forms via custom HTML pages. You can create the HTML page using any web development technique (DHTL, JS, Dojo, YUI, etc.). The HTML pages can be displayed inline inside the form or they can be triggered from the form as a modal dialog. ...

Community articleIBM Forms 4.0 HTML Extensions and YUI3 charts

Added by cees van der woude | Edited by IBM contributor cees van der woude on January 26, 2011 | Version 10
  • Edit
  • More Actions Show Menu▼
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars
expanded Abstract
collapsed Abstract
IBM 4.0 provides new hooks to add new functionality to your forms via custom HTML pages. You can create the HTML page using any web development technique (DHTL, JS, Dojo, YUI, etc.). The HTML pages can be displayed in-line inside the form or they can be triggered from the form as a modal dialog. This example will show a form with an in-line HTML page using YUI3 (Yahoo user Interface) charting components. The IBM Forms Javascript API is used to update the chart in real time when changes are made to the form.
Tags: HTML in a pane, YUI3, charts, XFDL, samples
ShowTable of Contents
HideTable of Contents
    • 0.1 HTML Extensions
    • 0.2 Building the Form
    • 0.3 Creating the HTML page
    • 0.4 Running the Sample
    • 0.5 Resources

HTML Extensions


HTML extensions is a new feature in IBM Forms. It allows to add new functionality via custom HTML pages that can be shown in-line or can be launched as a modal dialog. The IBM forms Javascript API can be used to commicate between the HTML page and the form. In this example we show a form with an expandable table where a user can fill in the monthly amounts for rent and utilities. An HTML pane inside the form references an HTML page hosted on the Webform Server. The page uses the YUI3 (Yahoo User Interface) charting component. The IBM Forms Javascript API is used to read an xforms instance from the form that contains the chart data. The chart data is then normalized and used to generate a chart.
 
The XFDL form with YUI3 chart
 

Building the Form



The Form contains a simple table added via the wizard. The corresponding Xforms instance looks as follows:
<xforms:instance id="CHARTDATA" xmlns="">

                  <data>

                     <items>

                        <item>

                           <month>jan</month>

                           <rent>900</rent>

                           <utilities>650</utilities>

                        </item>

                        <item>

                           <month>feb</month>

                           <rent>700</rent>

                           <utilities>600</utilities>

                        </item>

                        <item>

                           <month>mar</month>

                           <rent>950</rent>

                           <utilities>525</utilities>

                        </item>

                        <item>

                           <month>apr</month>

                           <rent>800</rent>

                           <utilities>450</utilities>

                        </item>

                     </items>

                  </data> 

 
There is also a field with ID TABLE_SUM which calculates the total of all the rental amounts and  all the utilities amounts. This field would normally not be visible. The Xforms bind that calculates the total looks as follows:
 
<xforms:bind calculate="if(string(sum(instance('CHARTDATA')/items/item/*[local-name()!=&quot;month&quot;][.!='']))='NaN','',sum(instance('CHARTDATA')/items/item/*[local-name()!=&quot;month&quot;][.!='']))" nodeset="instance('ChartMeta')/page1/sum_table"></xforms:bind> 

 
 Underneath the table the new HTML pane widget was added and the relative URL pointing to the HTML page was specified.
 
The XFDL form in Designer with the HTML pane
 
The Form is saved in a new directory called ExtensionCharts under the DevelopmentSamples directory  within the Webform Server samples framework that can be installed with Webform Server.
The path to this directory in a standard Webform Server installation would be:
 
C:\IBM\WebSphere\\installedApps\forms4\WebformSampleApp.ear\Samples.war\SampleForms\DevelopmentSamples\ExtensionChart
 

Creating the HTML page



The HTML page should be created in the same directory where the form was stored. The complete code for the HTML page is inserted below in 3 parts:
 
 Part 1 of HTML page
 
Note the following:
  • References to YUI3 framework and stylesheets. You must be online for these to be accessible. Alternatively, the framework can be downloaded and installed locally in which case the references should be adapted.
  • References to IBM Forms Javascript libraries. These are installed by default with the Webform Server Sample framework
 Part 2 of HTML page
 
 Note the following:
  • XFDL.getCurrentForm().extractXFormsInstance returns a string. YUI provides DataType module that can parse the string into an XML object
  • The YUI dataschema module can take different formats (JSON, XML, delimited text)  and return a normalized format that can serve as input for the chart module
  • In our case the input for the dataschema is XML so we specify a root node (item) and the ResultFields (month, rent, utilities)
 
 Part 3 of HTML page
 
 Note the following:
  • type: "combo" could be changed to e.g. line, area, column, bar
  • interactionType: "planar" adds default tool tips to the chart
  • There are many more options.....

Running the Sample


Once the XFDL form and HTML page are in place, make sure Webform Server Translater and Server1 are running. Point your browser to:
  • http://<your server>:<portnumber>/ Samples
  • Navigate to DevelopmentSamples -> ExtensionChart
  • Open ChartYUI3.xfdl
  • Try changing a value in the table, tab out of the field. The chart will update
  • Put your cursor in the bottom row of the table and click the + button to add a new row for the month of May. The chart will update

Resources


 
Resources files (XFDL and HTML) are available under attachments:
 
 

  • Edit
  • More Actions Show Menu▼


expanded Attachments (7)
collapsed Attachments (7)
Edit the article to add or modify attachments.
File TypeSizeFile NameCreated On
image/jpeg 80 KB FormWithChart.jpg 1/20/11 8:08 AM
image/jpeg 124 KB HTMLpane.jpg 1/20/11 8:08 AM
image/jpeg 124 KB HTMLPage1.jpg 1/20/11 8:08 AM
image/jpeg 144 KB HTMLPage2.jpg 1/20/11 8:08 AM
image/jpeg 75 KB HTMLPage3.jpg 1/20/11 8:08 AM
text/html 3 KB ExtensionChartYUI3.html 1/20/11 8:08 AM
application/octet-stream 13 KB ChartYUI3.xfdl 1/20/11 8:08 AM
expanded Versions (10)
collapsed Versions (10)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (10)Jan 26, 2011 9:22:04 AMcees van der woude  IBM contributor
9Jan 24, 2011 7:55:26 AMCornelis van der Woude  IBM contributor
8Jan 21, 2011 4:38:43 AMcees van der woude  IBM contributor
7Jan 21, 2011 4:36:59 AMcees van der woude  IBM contributor
6Jan 21, 2011 4:22:30 AMcees van der woude  IBM contributor
5Jan 20, 2011 2:48:15 PMcees van der woude  IBM contributor
4Jan 20, 2011 9:34:10 AMcees van der woude  IBM contributor
3Jan 20, 2011 9:21:40 AMcees van der woude  IBM contributor
2Jan 20, 2011 9:07:34 AMcees van der woude  IBM contributor
1Jan 20, 2011 8:08:51 AMcees van der woude  IBM contributor
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMSocialBizUX on Twitter
  • FacebookIBMSocialBizUX on Facebook
  • ForumsLotus product forums
  • BlogsIBM Social Business UX blog
  • Community LinkIBM Collaboration Solutions
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use