Generate xPages from your views
The Dublin workshop has concluded. Others have reported and I start playing with automating upgrading your existing applications to include xPages. In a nutshell: xPages allows scripting your application end-to-end in JavaScript. JavaScript on the client and the server and just a selection for you to decide what runs where. Of course JavaScript is not a Domino server languages in older Notes versions, so you need to do something about your @Formula and LotusScript. But that's a topic for another time. xPages are stored as XML. Existing Domino design elements can be exported with reasonably accuracy as DXL which is XML too. So with a little XSLT the both might be fit onto each other.
A Domino view starts with
As usual: YMMV
A Domino view starts with
<view name='
, while an xPage starts with <xp:viewPanel
. Different names but similar structure! A column in a Notes view is represented by <column itemname=,
the column in the xPage with <xp:viewColumn columnName=
. Again just different names. To get from all your views to xPages follow the following steps:
- Create one xPage that looks the way your stuff should look like
- Switch to the source view, cut and paste it into your favorite XSLT editor
- Replace the variable parts (the columns) with XSLT template logic. Save the file into [NotesData]/xsl
- Use the DXLTools - Transformer to apply that one by one to your views (you could script that)
- Switch to the Java perspective and import the resulting files back in your NSF
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xp="http://www.ibm.com/xsp/core" xmlns:d='http://www.lotus.com/dxl'> <xsl:output method="xml" indent="yes" /> <xsl:template match="/"> <xp:view xmlns:xp="http://www.ibm.com/xsp/core"> <xsl:apply-templates select="//d:view" /> </xp:view> </xsl:template> <xsl:template match="d:view"> <xsl:variable name="panelid"><xsl:value-of select="@name" /></xsl:variable> <xp:viewPanel rows="30" viewStyle="width:100%"> <xsl:attribute name="id">viewPanel<xsl:value-of select="$panelid" /></xsl:attribute> <xp:this.facets> <xp:pager layout="Previous Group Next" xp:key="headerPager" id="pager1"> </xp:pager> </xp:this.facets> <xp:this.data> <xp:dominoView> <xsl:attribute name="var"><xsl:value-of select="$panelid" /></xsl:attribute> <xsl:attribute name="viewName"><xsl:value-of select="$panelid" /></xsl:attribute> </xp:dominoView> </xp:this.data> <xsl:apply-templates select="d:column" /> </xp:viewPanel> </xsl:template> <xsl:template match="d:column"> <xsl:variable name="colid">viewColumn<xsl:value-of select="position()" /></xsl:variable> <xsl:variable name="headid">viewColumnHeader<xsl:value-of select="position()" /></xsl:variable> <xp:viewColumn> <xsl:attribute name="columnName"><xsl:value-of select="d:columnheader/@title" /></xsl:attribute> <xsl:attribute name="id"><xsl:value-of select="$colid" /></xsl:attribute> <xp:viewColumnHeader> <xsl:attribute name="value"><xsl:value-of select="d:columnheader/@title" /></xsl:attribute> <xsl:attribute name="id"><xsl:value-of select="$headid" /></xsl:attribute> </xp:viewColumnHeader> </xp:viewColumn> </xsl:template> </xsl:stylesheet>
As usual: YMMV
Posted by Stephan H Wissel on 31 August 2008 | Comments (0) | categories: Show-N-Tell Thursday