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

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Recently uploaded (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

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