Search

Languages

Other languages on request.

About Me

I am the "Lotus Technology & Productivity Advisor" for IBM Asia Pacific. I'm based in Singapore.

Ads by Google

Visitors

« Lotusphere 09 heating up. | Main| xPages Overview »

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 <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.
The sample is really short:

<?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>

YMMV

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::rolleyes:;-)

Disclaimer

This site is in no way affiliated, endorsed, sanctioned, supported, nor enlightened by Lotus Software nor IBM Corporation. I may be an employee, but the opinions, theories, facts, etc. presented here are my own and are in now way given in any official capacity. In short, these are my words and this is my site, not IBM's - and don't even begin to think otherwise. (Disclaimer shamelessly plugged from Rocky Oliver)

© 2003 - 2008 Stephan H. Wissel - all rights reserved as listed here: Unless otherwise labeled by its originating author, the content found on this site is made available under the terms of an Attribution/NonCommercial/ShareAlike Creative Commons License, with the exception that no rights are granted -- since they are not mine to grant -- in any logo, graphic design, trademarks or trade names of any type.

Get Firefox Use OpenDNS