SlideShare a Scribd company logo
1 of 34
Download to read offline
XPages Binary Output
Vi tales ved

The only limitation is your imagination

iZone

John Foldager, izone.dk
DanNotes November 28th 2013
About John Foldager
●

●

Born in 1974 and have been working with IT – especially
programming since the age of 7 – at iZone since 1999

Member of Notesnet.dk – association of approx. 25
independent consultants

●

Vice chairman of Eclipse.dk

●

Mentor at Egedal CoderDojo

●

Pro Cross-platform development (IBM i, Linux, Unix, BSD,
Windows, Solaris, AIX, Raspberry Pi, Android, …)

●

Pro Java/OSGi (scalability, deployment, extensibility, …)

●

Pro HTML5/CSS3/JavaScript

●

Follow me on Twitter

@JohnFoldager

iZone
Introduction
●

Normal use of XPages uses HTML, Dojo, IBM OneUI etc.

●

Sometimes other formats/content are needed
●

Text output
●

●

Binary output
●
●

●

●

XML (eXtensible Markup Language), JSON (JavaScript Object Notation), CSV
(Comma Separated Values), SVG (Scalable Vector Graphics), …

Media: images (PNG, JPEG, GIF, …), video (MPEG, …), sound (MP3, Ogg, …)
Document formats: PDF (Portable Document Format), OpenXPS (Open XML
Paper Specification), ODF (Open Document Format), OOXML (Office Open
XML), …
Other: SVG (Scalable Vector Graphics), Archives (ZIP, …), …

We will show how to...
●

use XPages, XAgents, NSF servlets and OSGi servlets

●

embed and/or download content

iZone
XAgents
●

Who uses XAgents [in the audience]?
●

●

●

First mentioned by Stefan Wissel on http://www.wissel.net/blog/d6plinks/shwl-7mgfbn

XAgents are XPages where property rendered is set to false
and some code is put into beforeRenderResponse (binary)
or afterRenderResponse (text)
Code is SSJS (Server Side JavaScript)
●

●

Evaluated at runtime (lower performance)

●

●

Easy and quick to write because you are on the same 'page'
Harder to debug and unit test

Some examples...
iZone
XAgents – XML example
●

Create an XPage where property rendered is set to false
and put the following code in the afterRenderResponse
(SSJS)
●

var external = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = external.getResponse();
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
writer.write("<?xml version='1.0' encoding='utf-8'?>rn");
writer.write("<say>Hello World!</say>");
writer.endDocument();
facesContext.responseComplete();

iZone
XAgents – JSON example
●

Create an XPage where property rendered is set to false
and put the following code in the afterRenderResponse
(SSJS)
●

var external = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = external.getResponse();
response.setContentType("application/json");
response.setHeader("Cache-Control", "no-cache");
writer.write("{rn");
writer.write(" 'say':'Hello World!'rn");
writer.write("}rn");
writer.endDocument();
facesContext.responseComplete();

iZone
XPages – Other formats
●

Who [in the audience] have tried to deliver non-standard HTML
from an XPage (without using XAgents) and having 100%
control of all content?
●

●

XPages can be set to create non-HTML content very easily
●

●

●

First mentioned by John Foldager on http://xpages.dk/?p=83

NOTE: Several guides on the Internet describes various ways of removing Dojo,
OneUI etc. – but none of them gives you absolutely full control of the entire content.
For the most part you overrule everything for all XPages inside the NSF, even though
you might only want to do so for a single XPage.

Only thing you need to do is set the rendererType to
javax.faces.Text and set createForm to false
Some examples...
iZone
XPages – Custom output (1)
●

Create a Hello World XPage

iZone
XPages – Custom output (2)
●

Change DOCTYPE to HTML5 compliant (globally inside NSF)

iZone
XPages – Custom output (2)
●

Change DOCTYPE to HTML5 compliant (globally inside NSF)

iZone
XPages – Custom output (3)
●

Expand includes (globally inside NSF)

iZone
XPages – Custom output (4)
●

Remove Dojo (globally inside NSF)

iZone
XPages – Custom output (5)
●

Remove form and fields (locally to current XPage)

iZone
XPages – Custom output (6)
●

Remove the rest (locally to current XPage)

iZone
XPages – Custom output (7)
●

Your own HTML5 content (locally to current XPage)

iZone
XPages – HTML5 example
●

Create an XPage with the following source
●

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" createForm="false" rendererType="javax.faces.Text">
<xp:this.afterRenderResponse><![CDATA[#{javascript:
var external = facesContext.getExternalContext();
var response = external.getResponse();
response.setContentType("text/html");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-store");
}]]></xp:this.afterRenderResponse>
<xp:text escape="false" disableTheme="true">
<xp:this.value><![CDATA[#{javascript:'<!DOCTYPE html>n'}]]></xp:this.value>
</xp:text>
<html lang="en">
<head>
<content encoding="utf-8"/>
<title>My HTML5 page</title>
</head>
<body>
<header><h1>My HTML5 page delivered from an XPage</h1></header>
</body>
</xp:view>

iZone
XPages – XML example #1
●

Create an XPage with the following source
●

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" createForm="false" rendererType="javax.faces.Text">
<xp:this.afterRenderResponse><![CDATA[#{javascript:
var external = facesContext.getExternalContext();
var response = external.getResponse();
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-store");
}]]></xp:this.afterRenderResponse>
<xp:text escape="false" disableTheme="true">
<xp:this.value><![CDATA[#{javascript:'<?xml version="1.0" encoding="utf-8" ?>n'}]]></xp:this.value>
</xp:text>
<say>Hello World!</say>
</xp:view>

iZone
XPages – XML example #2
●

Create an XPage with the following source
●

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" createForm="false" rendererType="javax.faces.Text">
<xp:this.afterRenderResponse><![CDATA[#{javascript:
var external = facesContext.getExternalContext();
var response = external.getResponse();
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-store");
}]]></xp:this.afterRenderResponse>
<xp:text escape="false" disableTheme="true">
<xp:this.value><![CDATA[#{javascript:'<?xml version="1.0" encoding="utf-8" ?>n'}]]></xp:this.value>
</xp:text>
<xp:repeat id="repeat" rows="30" var="dataentry" removeRepeat="true">
<xp:this.facets>
<xp:text disableTheme="true" xp:key="header" escape="false">
<xp:this.value><![CDATA[<customers>]]></xp:this.value>
</xp:text>
<xp:text disableTheme="true" xp:key="footer" escape="false">
<xp:this.value><![CDATA[</customers>]]></xp:this.value>
</xp:text>
</xp:this.facets>
<xp:this.value><![CDATA[#{javascript:[1,2,3,4]}]]></xp:this.value>
<xp:text escape="false" disableTheme="true">
<xp:this.value><![CDATA[#{javascript:"<customer>" + dataentry + "</customer>n"}]]></xp:this.value>
</xp:text>
</xp:repeat>

iZone

</xp:view>
What did we learn so far?
●

●

Now we know how to create our own content from an XPage
(disabling all defaults) and from an XAgent (XPage)
So what exactly did we learn?
●

We learned how to overrule whatever XPage engine is normally generating

●

We learned how to use XPages repeat-control and Data Source

●

We learned how to set the Content Type

●

We learned how to set headers (fx. Caching)

●

We basically learned that XPages can be used for sooooooo much more than what we
normally use it for

iZone
Download?
●

How can we make the browser download the content?
●

This is actually pretty easy. We just need to add another HTTP Header to the response
●

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" createForm="false" rendererType="javax.faces.Text">
<xp:this.afterRenderResponse><![CDATA[#{javascript:
var external = facesContext.getExternalContext();
var response = external.getResponse();
response.setContentType("text/plain");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-store");
response.setHeader("Content-Disposition", "attachment; filename=MyFilename.txt");
}]]></xp:this.afterRenderResponse>
Hello World!
</xp:view>

iZone
Even more control?
●

So can we get even more control?
●

●

●

●

YES!

We can use servlets either from inside the NSF or using an
OSGi bundle, but before we get to that...
We will try to create a Java class that can be called from a
button or link on a normal XPage to download some content
An example...

iZone
Download from XPage (1)
●

Steps to follow

Remember Per Henrik Lausten's presentation earlier today?

●

Create a Java Managed Bean class to deliver content

●

Create entry for bean in faces-config.xml

●

Create button or link on XPage to call bean

iZone
Download from XPage (2)
●

Steps to follow
●

Create a Java Managed Bean class to deliver content
●

package dk.izone.demos.download;
import
import
import
import
import
import
import

java.io.IOException;
java.io.OutputStream;
java.io.Serializable;
javax.faces.context.ExternalContext;
javax.faces.context.FacesContext;
com.ibm.xsp.webapp.XspHttpServletResponse;
dk.izone.demos.utils.io.FileIO;

public class DownloadBean implements Serializable {
private static final long serialVersionUID = 1L;
public DownloadBean() {}
public void download() {
try {
byte[] file = FileIO.readFile("C:tempMyArchive.zip");
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext external = context.getExternalContext();
XspHttpServletResponse response = (XspHttpServletResponse) external.getResponse();
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "attachment; filename=MyArchive.zip");
response.setHeader("Content-Length", String.valueOf(file.length));
OutputStream os = response.getOutputStream();
os.write(file);
os.close();
context.responseComplete();
} catch (IOException e) {
e.printStackTrace();
}
}

}

iZone
Download from XPage (3)
●

Steps to follow
●

Create a Java Managed Bean class to deliver content

●

Create entry for bean in faces-config.xml
●

<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
<managed-bean>
<managed-bean-name>MyBean</managed-bean-name>
<managed-bean-class>dk.izone.demos.download.DownloadBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
</faces-config>

iZone
Download from XPage (4)
●

Steps to follow
●

Create a Java Managed Bean class to deliver content

●

Create entry for bean in faces-config.xml

●

Create button or link on XPage to call bean
●

●

<xp:button id="button1" value="Download">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:MyBean.download();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:link id="link1" text="Download">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:MyBean.download();}]]></xp:this.action>
</xp:eventHandler>
</xp:link>

iZone
Acknowledgement
●

The previous example is a rewrite of an example by Jakob
Majkilde which can be found on http://xpages.dk/?p=1396

iZone
Standard Java? #1
●

Can we get even more control and use standard Java?
●

●

●

YES!

We can use Java Servlets either from inside the NSF or using
an OSGi bundle. We will start by showing the NSF way...
We will show a Java Servlet that
●

will reside inside the NSF so that it can be deployed like we
“use to”

●

●

●

looks “a little bit” like a real standard Java Servlet
core Java developers should be able to work from template

An example...
iZone
Standard Java? #1
●

Depend on Extension Library

●

Create Java class that extends DefaultServletFactory

●

●

Create file META-INF/services/
com.ibm.xsp.adapter.servletFactory and put Java
class package and name in
An example...

iZone
Standard Java? #2
●

Can we create standard Java Servlets using Eclipse IDE (or
any other IDE based on Eclipse) and deploy to the Domino
server as an OSGi bundle?
●

●

●

YES! We can even do it using an Update Site :-)

We can create servlets to either an Equinox HTTP Service or
Expeditor Web Container (J2EE)
We will show a Java servlet that
●

●

is a real standard Java Servlet

●

●

is an Eclipse OSGi plugin project
core Java developers should be able to work right away

An example...

iZone
Standard Java? #2
●

An example...

iZone
rd

3 Party Java API Deployment
●

●

There are plenty of Java APIs that can be downloaded on the
Internet and used for various purposes
Examples
●

●

Images

●

Barcodes (Barcode4J, …)

●

Office Files (Apache POI, ODF Toolkit, OOXML, …)

●

PDFs (Apache PDF Box, iText, …)

●

●

Apache Software Foundation (apache.org)

etc.

So lets see how we can deploy these 3rd party Java APIs using
OSGi bundles
iZone
Need Help?
●

You are more than welcome to contact “Gang of Four”
●

Jakob Majkilde, majkilde.dk

●

Per Henrik Lausten, phl-consult.dk

●

John Dalsgaard, dalsgaard-data.dk

●

John Foldager, izone.dk

iZone
Links
●

Here are some links that refer to related information
●

DOCTYPE – http://www.dominoguru.com/pages/change_xpage_doctype.html

●

Domino OSGi development – http://www.slideshare.net/fiorep/domino-osgi-development

iZone
Questions? Contact!
●

You are more than welcome to contact me directly
●

Website: http://izone.dk

●

Phone: +45 20 22 22 11

●

Email: john.foldager@izone.dk

●

LinkedIn: http://dk.linkedin.com/in/foldager

●

Twitter: @JohnFoldager

●

Google+: +JohnFoldager

●

http://john.foldager.tel

iZone

More Related Content

What's hot

Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014Endava
 
The Dojo Toolkit An Introduction
The Dojo Toolkit   An IntroductionThe Dojo Toolkit   An Introduction
The Dojo Toolkit An IntroductionJeff Fox
 
Bootstrap4XPages webinar
Bootstrap4XPages webinarBootstrap4XPages webinar
Bootstrap4XPages webinarMark Leusink
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoFu Cheng
 
How dojo works
How dojo worksHow dojo works
How dojo worksAmit Tyagi
 
Bootstrap and XPages (DanNotes 2013)
Bootstrap and XPages (DanNotes 2013)Bootstrap and XPages (DanNotes 2013)
Bootstrap and XPages (DanNotes 2013)Mark Leusink
 
jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks TriviaCognizant
 
Introduction Dojo Toolkit & IBM Lotus Domino
Introduction Dojo Toolkit & IBM Lotus DominoIntroduction Dojo Toolkit & IBM Lotus Domino
Introduction Dojo Toolkit & IBM Lotus DominoRolf Kremer
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web AppsTimothy Fisher
 
2013 04-02-server-side-backbone
2013 04-02-server-side-backbone2013 04-02-server-side-backbone
2013 04-02-server-side-backboneSC5.io
 
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!Frédéric Harper
 
Developing Your Ultimate Package
Developing Your Ultimate PackageDeveloping Your Ultimate Package
Developing Your Ultimate PackageSimon Collison
 
Building Web Sites that Work Everywhere
Building Web Sites that Work EverywhereBuilding Web Sites that Work Everywhere
Building Web Sites that Work EverywhereDoris Chen
 
Incremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend DevelopmentIncremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend DevelopmentAkihiro Ikezoe
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...Horacio Gonzalez
 
2011淘宝首页开发实践
2011淘宝首页开发实践2011淘宝首页开发实践
2011淘宝首页开发实践jay li
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...Horacio Gonzalez
 

What's hot (20)

Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014
 
The Dojo Toolkit An Introduction
The Dojo Toolkit   An IntroductionThe Dojo Toolkit   An Introduction
The Dojo Toolkit An Introduction
 
Bootstrap4XPages webinar
Bootstrap4XPages webinarBootstrap4XPages webinar
Bootstrap4XPages webinar
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojo
 
Zero To Dojo
Zero To DojoZero To Dojo
Zero To Dojo
 
How dojo works
How dojo worksHow dojo works
How dojo works
 
Bootstrap and XPages (DanNotes 2013)
Bootstrap and XPages (DanNotes 2013)Bootstrap and XPages (DanNotes 2013)
Bootstrap and XPages (DanNotes 2013)
 
jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks Trivia
 
Introduction Dojo Toolkit & IBM Lotus Domino
Introduction Dojo Toolkit & IBM Lotus DominoIntroduction Dojo Toolkit & IBM Lotus Domino
Introduction Dojo Toolkit & IBM Lotus Domino
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web Apps
 
2013 04-02-server-side-backbone
2013 04-02-server-side-backbone2013 04-02-server-side-backbone
2013 04-02-server-side-backbone
 
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
 
Developing Your Ultimate Package
Developing Your Ultimate PackageDeveloping Your Ultimate Package
Developing Your Ultimate Package
 
Building Web Sites that Work Everywhere
Building Web Sites that Work EverywhereBuilding Web Sites that Work Everywhere
Building Web Sites that Work Everywhere
 
Incremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend DevelopmentIncremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend Development
 
ActiveDOM
ActiveDOMActiveDOM
ActiveDOM
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
 
2011淘宝首页开发实践
2011淘宝首页开发实践2011淘宝首页开发实践
2011淘宝首页开发实践
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
 
Edge of the Web
Edge of the WebEdge of the Web
Edge of the Web
 

Similar to XPages Binary Output

jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoiddmethvin
 
How to make Ajax Libraries work for you
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for youSimon Willison
 
Experiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseExperiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseMarcelo Ochoa
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsOWASP Kyiv
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James NelsonGWTcon
 
Go debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFxGo debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFxSignalFx
 
Node.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsNode.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsManuel Eusebio de Paz Carmona
 
Unit Testing With Javascript
Unit Testing With JavascriptUnit Testing With Javascript
Unit Testing With Javascriptthedumbterminal
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScriptJorg Janke
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureSimon Willison
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Per Henrik Lausten
 
Grant Rogerson SDEC2015
Grant Rogerson SDEC2015Grant Rogerson SDEC2015
Grant Rogerson SDEC2015Grant Rogerson
 

Similar to XPages Binary Output (20)

jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
 
JS class slides (2016)
JS class slides (2016)JS class slides (2016)
JS class slides (2016)
 
JS Class 2016
JS Class 2016JS Class 2016
JS Class 2016
 
How to make Ajax Libraries work for you
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for you
 
Experiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseExperiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the Database
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
 
Nodejs
NodejsNodejs
Nodejs
 
JavaScript-Core
JavaScript-CoreJavaScript-Core
JavaScript-Core
 
JavaScript-Core
JavaScript-CoreJavaScript-Core
JavaScript-Core
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson
 
Go debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFxGo debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFx
 
Node.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsNode.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first steps
 
Unit Testing With Javascript
Unit Testing With JavascriptUnit Testing With Javascript
Unit Testing With Javascript
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big Picture
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)
 
Kommons
KommonsKommons
Kommons
 
Grant Rogerson SDEC2015
Grant Rogerson SDEC2015Grant Rogerson SDEC2015
Grant Rogerson SDEC2015
 

Recently uploaded

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Recently uploaded (20)

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

XPages Binary Output

  • 1. XPages Binary Output Vi tales ved The only limitation is your imagination iZone John Foldager, izone.dk DanNotes November 28th 2013
  • 2. About John Foldager ● ● Born in 1974 and have been working with IT – especially programming since the age of 7 – at iZone since 1999 Member of Notesnet.dk – association of approx. 25 independent consultants ● Vice chairman of Eclipse.dk ● Mentor at Egedal CoderDojo ● Pro Cross-platform development (IBM i, Linux, Unix, BSD, Windows, Solaris, AIX, Raspberry Pi, Android, …) ● Pro Java/OSGi (scalability, deployment, extensibility, …) ● Pro HTML5/CSS3/JavaScript ● Follow me on Twitter @JohnFoldager iZone
  • 3. Introduction ● Normal use of XPages uses HTML, Dojo, IBM OneUI etc. ● Sometimes other formats/content are needed ● Text output ● ● Binary output ● ● ● ● XML (eXtensible Markup Language), JSON (JavaScript Object Notation), CSV (Comma Separated Values), SVG (Scalable Vector Graphics), … Media: images (PNG, JPEG, GIF, …), video (MPEG, …), sound (MP3, Ogg, …) Document formats: PDF (Portable Document Format), OpenXPS (Open XML Paper Specification), ODF (Open Document Format), OOXML (Office Open XML), … Other: SVG (Scalable Vector Graphics), Archives (ZIP, …), … We will show how to... ● use XPages, XAgents, NSF servlets and OSGi servlets ● embed and/or download content iZone
  • 4. XAgents ● Who uses XAgents [in the audience]? ● ● ● First mentioned by Stefan Wissel on http://www.wissel.net/blog/d6plinks/shwl-7mgfbn XAgents are XPages where property rendered is set to false and some code is put into beforeRenderResponse (binary) or afterRenderResponse (text) Code is SSJS (Server Side JavaScript) ● ● Evaluated at runtime (lower performance) ● ● Easy and quick to write because you are on the same 'page' Harder to debug and unit test Some examples... iZone
  • 5. XAgents – XML example ● Create an XPage where property rendered is set to false and put the following code in the afterRenderResponse (SSJS) ● var external = facesContext.getExternalContext(); var writer = facesContext.getResponseWriter(); var response = external.getResponse(); response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); writer.write("<?xml version='1.0' encoding='utf-8'?>rn"); writer.write("<say>Hello World!</say>"); writer.endDocument(); facesContext.responseComplete(); iZone
  • 6. XAgents – JSON example ● Create an XPage where property rendered is set to false and put the following code in the afterRenderResponse (SSJS) ● var external = facesContext.getExternalContext(); var writer = facesContext.getResponseWriter(); var response = external.getResponse(); response.setContentType("application/json"); response.setHeader("Cache-Control", "no-cache"); writer.write("{rn"); writer.write(" 'say':'Hello World!'rn"); writer.write("}rn"); writer.endDocument(); facesContext.responseComplete(); iZone
  • 7. XPages – Other formats ● Who [in the audience] have tried to deliver non-standard HTML from an XPage (without using XAgents) and having 100% control of all content? ● ● XPages can be set to create non-HTML content very easily ● ● ● First mentioned by John Foldager on http://xpages.dk/?p=83 NOTE: Several guides on the Internet describes various ways of removing Dojo, OneUI etc. – but none of them gives you absolutely full control of the entire content. For the most part you overrule everything for all XPages inside the NSF, even though you might only want to do so for a single XPage. Only thing you need to do is set the rendererType to javax.faces.Text and set createForm to false Some examples... iZone
  • 8. XPages – Custom output (1) ● Create a Hello World XPage iZone
  • 9. XPages – Custom output (2) ● Change DOCTYPE to HTML5 compliant (globally inside NSF) iZone
  • 10. XPages – Custom output (2) ● Change DOCTYPE to HTML5 compliant (globally inside NSF) iZone
  • 11. XPages – Custom output (3) ● Expand includes (globally inside NSF) iZone
  • 12. XPages – Custom output (4) ● Remove Dojo (globally inside NSF) iZone
  • 13. XPages – Custom output (5) ● Remove form and fields (locally to current XPage) iZone
  • 14. XPages – Custom output (6) ● Remove the rest (locally to current XPage) iZone
  • 15. XPages – Custom output (7) ● Your own HTML5 content (locally to current XPage) iZone
  • 16. XPages – HTML5 example ● Create an XPage with the following source ● <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" createForm="false" rendererType="javax.faces.Text"> <xp:this.afterRenderResponse><![CDATA[#{javascript: var external = facesContext.getExternalContext(); var response = external.getResponse(); response.setContentType("text/html"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-store"); }]]></xp:this.afterRenderResponse> <xp:text escape="false" disableTheme="true"> <xp:this.value><![CDATA[#{javascript:'<!DOCTYPE html>n'}]]></xp:this.value> </xp:text> <html lang="en"> <head> <content encoding="utf-8"/> <title>My HTML5 page</title> </head> <body> <header><h1>My HTML5 page delivered from an XPage</h1></header> </body> </xp:view> iZone
  • 17. XPages – XML example #1 ● Create an XPage with the following source ● <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" createForm="false" rendererType="javax.faces.Text"> <xp:this.afterRenderResponse><![CDATA[#{javascript: var external = facesContext.getExternalContext(); var response = external.getResponse(); response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-store"); }]]></xp:this.afterRenderResponse> <xp:text escape="false" disableTheme="true"> <xp:this.value><![CDATA[#{javascript:'<?xml version="1.0" encoding="utf-8" ?>n'}]]></xp:this.value> </xp:text> <say>Hello World!</say> </xp:view> iZone
  • 18. XPages – XML example #2 ● Create an XPage with the following source ● <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" createForm="false" rendererType="javax.faces.Text"> <xp:this.afterRenderResponse><![CDATA[#{javascript: var external = facesContext.getExternalContext(); var response = external.getResponse(); response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-store"); }]]></xp:this.afterRenderResponse> <xp:text escape="false" disableTheme="true"> <xp:this.value><![CDATA[#{javascript:'<?xml version="1.0" encoding="utf-8" ?>n'}]]></xp:this.value> </xp:text> <xp:repeat id="repeat" rows="30" var="dataentry" removeRepeat="true"> <xp:this.facets> <xp:text disableTheme="true" xp:key="header" escape="false"> <xp:this.value><![CDATA[<customers>]]></xp:this.value> </xp:text> <xp:text disableTheme="true" xp:key="footer" escape="false"> <xp:this.value><![CDATA[</customers>]]></xp:this.value> </xp:text> </xp:this.facets> <xp:this.value><![CDATA[#{javascript:[1,2,3,4]}]]></xp:this.value> <xp:text escape="false" disableTheme="true"> <xp:this.value><![CDATA[#{javascript:"<customer>" + dataentry + "</customer>n"}]]></xp:this.value> </xp:text> </xp:repeat> iZone </xp:view>
  • 19. What did we learn so far? ● ● Now we know how to create our own content from an XPage (disabling all defaults) and from an XAgent (XPage) So what exactly did we learn? ● We learned how to overrule whatever XPage engine is normally generating ● We learned how to use XPages repeat-control and Data Source ● We learned how to set the Content Type ● We learned how to set headers (fx. Caching) ● We basically learned that XPages can be used for sooooooo much more than what we normally use it for iZone
  • 20. Download? ● How can we make the browser download the content? ● This is actually pretty easy. We just need to add another HTTP Header to the response ● <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" createForm="false" rendererType="javax.faces.Text"> <xp:this.afterRenderResponse><![CDATA[#{javascript: var external = facesContext.getExternalContext(); var response = external.getResponse(); response.setContentType("text/plain"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-store"); response.setHeader("Content-Disposition", "attachment; filename=MyFilename.txt"); }]]></xp:this.afterRenderResponse> Hello World! </xp:view> iZone
  • 21. Even more control? ● So can we get even more control? ● ● ● ● YES! We can use servlets either from inside the NSF or using an OSGi bundle, but before we get to that... We will try to create a Java class that can be called from a button or link on a normal XPage to download some content An example... iZone
  • 22. Download from XPage (1) ● Steps to follow Remember Per Henrik Lausten's presentation earlier today? ● Create a Java Managed Bean class to deliver content ● Create entry for bean in faces-config.xml ● Create button or link on XPage to call bean iZone
  • 23. Download from XPage (2) ● Steps to follow ● Create a Java Managed Bean class to deliver content ● package dk.izone.demos.download; import import import import import import import java.io.IOException; java.io.OutputStream; java.io.Serializable; javax.faces.context.ExternalContext; javax.faces.context.FacesContext; com.ibm.xsp.webapp.XspHttpServletResponse; dk.izone.demos.utils.io.FileIO; public class DownloadBean implements Serializable { private static final long serialVersionUID = 1L; public DownloadBean() {} public void download() { try { byte[] file = FileIO.readFile("C:tempMyArchive.zip"); FacesContext context = FacesContext.getCurrentInstance(); ExternalContext external = context.getExternalContext(); XspHttpServletResponse response = (XspHttpServletResponse) external.getResponse(); response.setContentType("application/zip"); response.setHeader("Content-Disposition", "attachment; filename=MyArchive.zip"); response.setHeader("Content-Length", String.valueOf(file.length)); OutputStream os = response.getOutputStream(); os.write(file); os.close(); context.responseComplete(); } catch (IOException e) { e.printStackTrace(); } } } iZone
  • 24. Download from XPage (3) ● Steps to follow ● Create a Java Managed Bean class to deliver content ● Create entry for bean in faces-config.xml ● <?xml version="1.0" encoding="UTF-8"?> <faces-config> <managed-bean> <managed-bean-name>MyBean</managed-bean-name> <managed-bean-class>dk.izone.demos.download.DownloadBean</managed-bean-class> <managed-bean-scope>application</managed-bean-scope> </managed-bean> </faces-config> iZone
  • 25. Download from XPage (4) ● Steps to follow ● Create a Java Managed Bean class to deliver content ● Create entry for bean in faces-config.xml ● Create button or link on XPage to call bean ● ● <xp:button id="button1" value="Download"> <xp:eventHandler event="onclick" submit="true" refreshMode="complete"> <xp:this.action><![CDATA[#{javascript:MyBean.download();}]]></xp:this.action> </xp:eventHandler> </xp:button> <xp:link id="link1" text="Download"> <xp:eventHandler event="onclick" submit="true" refreshMode="complete"> <xp:this.action><![CDATA[#{javascript:MyBean.download();}]]></xp:this.action> </xp:eventHandler> </xp:link> iZone
  • 26. Acknowledgement ● The previous example is a rewrite of an example by Jakob Majkilde which can be found on http://xpages.dk/?p=1396 iZone
  • 27. Standard Java? #1 ● Can we get even more control and use standard Java? ● ● ● YES! We can use Java Servlets either from inside the NSF or using an OSGi bundle. We will start by showing the NSF way... We will show a Java Servlet that ● will reside inside the NSF so that it can be deployed like we “use to” ● ● ● looks “a little bit” like a real standard Java Servlet core Java developers should be able to work from template An example... iZone
  • 28. Standard Java? #1 ● Depend on Extension Library ● Create Java class that extends DefaultServletFactory ● ● Create file META-INF/services/ com.ibm.xsp.adapter.servletFactory and put Java class package and name in An example... iZone
  • 29. Standard Java? #2 ● Can we create standard Java Servlets using Eclipse IDE (or any other IDE based on Eclipse) and deploy to the Domino server as an OSGi bundle? ● ● ● YES! We can even do it using an Update Site :-) We can create servlets to either an Equinox HTTP Service or Expeditor Web Container (J2EE) We will show a Java servlet that ● ● is a real standard Java Servlet ● ● is an Eclipse OSGi plugin project core Java developers should be able to work right away An example... iZone
  • 30. Standard Java? #2 ● An example... iZone
  • 31. rd 3 Party Java API Deployment ● ● There are plenty of Java APIs that can be downloaded on the Internet and used for various purposes Examples ● ● Images ● Barcodes (Barcode4J, …) ● Office Files (Apache POI, ODF Toolkit, OOXML, …) ● PDFs (Apache PDF Box, iText, …) ● ● Apache Software Foundation (apache.org) etc. So lets see how we can deploy these 3rd party Java APIs using OSGi bundles iZone
  • 32. Need Help? ● You are more than welcome to contact “Gang of Four” ● Jakob Majkilde, majkilde.dk ● Per Henrik Lausten, phl-consult.dk ● John Dalsgaard, dalsgaard-data.dk ● John Foldager, izone.dk iZone
  • 33. Links ● Here are some links that refer to related information ● DOCTYPE – http://www.dominoguru.com/pages/change_xpage_doctype.html ● Domino OSGi development – http://www.slideshare.net/fiorep/domino-osgi-development iZone
  • 34. Questions? Contact! ● You are more than welcome to contact me directly ● Website: http://izone.dk ● Phone: +45 20 22 22 11 ● Email: john.foldager@izone.dk ● LinkedIn: http://dk.linkedin.com/in/foldager ● Twitter: @JohnFoldager ● Google+: +JohnFoldager ● http://john.foldager.tel iZone