SlideShare uma empresa Scribd logo
1 de 44
© 2011 IBM Corporation
BP211 XPages Blast
Matt White | Lead Developer | Elguji Software
Tim Clark | Tech Sales | IBM Lotus
2© 2011 IBM Corporation
Matt White
• Lead Developer at
• Creators of IdeaJam™ and IQJam™
• Creator of XPages101.net
• Founder member of the LDC
2
3© 2011 IBM Corporation
Tim Clark
• 17 years in IBM® Lotus®
• Support, Sales and Channel
• Creator of the X Cast, XPages podcast
• http://www.thexcast.net
3
4© 2011 IBM Corporation
Products we’re using
• IBM® Lotus Domino® Server 8.5.2
• Most of the session is based on 8.5.2, where we use earlier versions we’ll mention it
• IBM® Lotus Notes® 8.5.2
• IBM® Lotus Domino Designer® 8.5.2
4
5© 2011 IBM Corporation
Agenda
• General Programming Tips
• Debugging
• UI
• Notes Client
• Dojo
5
6© 2011 IBM Corporation
Tip Grading
• Beginner
• Intermediate
• Advanced
6
7© 2011 IBM Corporation
Sample Database
• You can download a database which demonstrates a lot of tips we talk about
here:
http://tinyurl.com/ls11xpagesblast
7
8© 2011 IBM Corporation
General Programming Tips
• Those useful bits and pieces that make your coding day fly by!
8
9© 2011 IBM Corporation
1. Scoped Variables
• applicationScope
• use to store data for all users of the app
• sessionScope
• use to store data for the current user
• viewScope
• use to store data for the current page
• requestScope
• use to store data for a single round trip to the server
9
scopedvariables.xsp
10© 2011 IBM Corporation
2. Repeat ANY data
• Repeat controls can be used with any type of data, not just view data.
• As long as the data is a list of some sort and you know how to reference it
• @Functions can return a string or a list, to make sure the results work, use this
$A function:
• http://tinyurl.com/xpbrepeats
10
repeats.xsp
11© 2011 IBM Corporation
3. Calling an Agent in 8.5.0 or 8.5.1
• Don’t do it unless you really need to!
• Running code as a different user (e.g. an admin)
• You’ll probably end up having to save the document twice, so it’s very
expensive.
• However, if you really have to...
var agent:NotesAgent = database.getAgent(“myagent”);
agent.runOnServer(noteid);
• Or you can always call an old style agent URL using AJAX (we’ll show you how
later on)
11
12© 2011 IBM Corporation
4. Calling an Agent in 8.5.2 +
• In 8.5.2 you can call an agent and pass an “in memory” document to it:
Agent.runWithDocumentContext(NotesDocument)
• There are also three different types of session object available:
• session - the current user’s session
• sessionAsSigner - a session running as the XPage signer
• sessionAsSignerWithFullAccess - a session running as the XPage signer
giving full admin rights
• Running SSJS is always going to be faster than calling an agent
12
13© 2011 IBM Corporation
5. ACLs in XPages
• If not done, people may be able to create documents that you are not expecting
• Go to All Properties > Data > ACL and add ACL settings
• Settings can be made for:
• Default
• Anonymous
• Individuals
• Groups
• Roles
13
14© 2011 IBM Corporation
6. #{id:mycontrol}
• Used if you want to know what the id of the field will be at runtime
• Use this syntax to identify a specific field:
• Also works in reused controls
14
clientsidereferences.xsp
15© 2011 IBM Corporation
7. Calling SSJS in CSJS
• If you want to pass server side data to the client side as the page loads you
can use:
#{javascript:myfunction()}
• Returns the result of “myfunction” at runtime inside your CSJS
15
clientsidereferences.xsp
16© 2011 IBM Corporation
• A free download from OpenNTF:
http://extlib.openntf.org/
• Provides a whole bunch of extra controls for your
XPages
• Just needs a simple install on the server to enable to
extra controls
16
8. Extension Library
17© 2011 IBM Corporation
9. Localisation
• Easy to do
• Turn it on
• Pick which languages you want to support
• Edit the translation files
• You’re done. ;o)
17
18
• When you add the custom control to an XPage, the Custom Properties tab of
the custom control contains the list of all of the different properties which you
can set
© 2011 IBM Corporation
10. Custom Properties
• It’s very easy to pass data around different
custom controls
• In the Custom Control properties go to the
Property Definition section
• Add a new property for each setting
• Can be any data type (e.g. String, Boolean,
Document data etc)
• Can have a default value if the property is not
set when the custom control is used
18
19© 2011 IBM Corporation
11. Using Java classes
• Great for network operations and other pre-rolled Java functionality
• Create a “lib” folder using the package explorer
• Import your .jar file
• Refer to the full package structure or use “importPackage”
importPackage(com.xpagesblast.demo);
var text = getComponent("inputtext").getValue();
var speaker:SaySomething = new SaySomething(text);
getComponent("out").setValue(speaker.whatDoYouSay());
19
java.xsp
20© 2011 IBM Corporation
12. Using an XPage as a servlet
• If you want to get the memory resident benefits of an XPage but don’t want to
return HTML then...
• Set the rendered property to False
• In afterRenderResponse event return required data:
try{
var exCon = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = exCon.getResponse();
response.setContentType("text/plain");
writer.write("Hello World");
writer.endDocument();
facesContext.responseComplete();
writer.close(); //Leave this line out in 8.5.2
}catch(e){
_dump(e);
}
20
servlet.xsp
21© 2011 IBM Corporation
13. IgnoreRequestParams
• Control individual document bindings on a single XPage
• In All Properties > Data > Data > dominoDocument, set ignoreRequestParams
to false
• Then whatever default action you have defined for the document data binding
will take precedence over the URL Parameters
• Useful for blog comments
21
requestparams.xsp
22© 2011 IBM Corporation
Debugging
• Because although we never create bugs, sometimes more information is useful
22
23© 2011 IBM Corporation
14. Configure Firewall
• A lot of local firewalls block ports on the local machine
• You’re basically running a local IBM® Websphere® server on a port somewhere
in the 30,000+ range
• You will never see an error so it’s difficult to debug
• Either disable the firewall or work out a rule which allows the server to run
23
24© 2011 IBM Corporation
15. Turn on debugging
• In the Application properties, check the “Display XPages Runtime
Error Page” box.
• Then when there is an error in your code you’ll get a more useful
message
24
25© 2011 IBM Corporation 25
Error Code Most Likely Cause
500 There’s an error in your code. Idiot ;-)
404 A typo in your URL. Remember the XPage name
is case sensitive
403 Forbidden error, the signing ID doesn’t have
rights to run XPages
302 Shows up a lot in server logs. It’s a redirection
and can be ignored.
16. Common Error Messages
26© 2011 IBM Corporation
17. Use OpenLog
• Download OpenLog from OpenNTF
http://www.openntf.org/projects/pmt.nsf/ProjectLookup/OpenLog
• Download TaskJam (which has the script library in) from OpenNTF
• At the top of your SSJS
import OpenLogXPages
• Implement using
log.logEvent("Clearing the Cache", SEVERITY_LOW,
"serverSide", "resetApplicationScope", null);
• or
log.logError(“There was an error”, SEVERITY_HIGH,
“Error Message”, “Error Number”, “Location”, “Method”,
“Error Line”, document);
26
27© 2011 IBM Corporation
18. Use Firebug
• The single most important debugging tool for XPages
• Lets you inspect HTML, CSS and CSJS
• Network operations and AJAX requests
• Download from Tools in Firefox or
http://getfirebug.com
• In CSJS use
dojo.console(“message”);
27
28© 2011 IBM Corporation
User Interface
• Because even though we’re programmers, the UI is important
28
29© 2011 IBM Corporation
19. Themes & Global Config
• Want to set something once and have it used everywhere, use Themes
• Can set; stylesheets, classes on elements or pick a skin dynamically using
simple XML, for example:
<theme>
<resource>
<content-type>text/css</content-type>
<href>custom.css</href>
</resource>
<control>
<name>InputField.RichText</name>
<property mode="concat">
<name>styleClass</name>
<value>domino-richtext
xspInputFieldRichText</value>
</property>
</control>
</theme>
29
30© 2011 IBM Corporation
• OneUI - http://tinyurl.com/xpboneui
• Download “XPages framework” from OpenNTF
• Or use the OneUI control in the Extension Library
• Blueprint - http://tinyurl.com/xpbblueprint
• 960 Grid - http://tinyurl.com/xpb960grid
• Doesn’t matter which one, just USE ONE!!!!!
30
20. Use a CSS Framework
31© 2011 IBM Corporation
XPages in Notes Client
• XPiNC
31
32© 2011 IBM Corporation
• If manually building URLs for the Notes Client
• In 8.5.1 you HAVE TO add the SessionID parameter:
&SessionID=tclk48931240
• Error 503 with no other explanation if you don’t add it
• It’s been fixed in 8.5.2
32
21. Use &SessionID
33© 2011 IBM Corporation
22. View Page Source
• Toolbar button only available if Designer installed
• Shows the source HTML of XPages in Notes client
• Useful because the HTML in the Notes Client is not always the same as in a
web browser
33
34© 2011 IBM Corporation
23. View Logs in Notes Client
• From menu
• Help, Support, View Trace
• Where the print statement output from SSJS is displayed
• SSJS output only, CSJS output is not visible in XPiNC
34
35© 2011 IBM Corporation
24. Difference in URLs
• If you manually build URLs be aware that there are different structures
between the Notes Client and the web browser:
• Web Browser
/directory/XPagesBlast.nsf/test.xsp
• Notes Client
/xsp/ServerName!!directory/XPagesBlast.nsf/test.xsp
35
36© 2011 IBM Corporation
Dojo
• Not the fight place!
36
37© 2011 IBM Corporation
25. Enable parseOnLoad
• If you have Dojo widgets on your XPage then you should set this to true, to
have them automatically initialize
• Unless you want to manually initialise Dojo Elements yourself using Javascript
37
38© 2011 IBM Corporation
26. Dialog box
• If you want to interact with the server from inside your dialog box. You have to
work around a “feature”.
• Best option is to use Jeremy Hodge’s approach: http://tinyurl.com/xpbdialog
• Include CSJS Library in your XPage, then enable dojoParseOnLoad and
dojoTheme
“feature” = BUG
38
dialog.xsp
39© 2011 IBM Corporation
27. Dojo Ajax Request
• Writing your own Ajax can still be useful, simply use the xhr API:
39
ajax.xsp
40© 2011 IBM Corporation
28. Charting
• dojox.charting offers a huge array of charting options
• For a simple pie chart
• import the basic modules
• add the data (formatted as JSON)
• add CSJS to initialize the chart
• No flash required
• offers animation
• Tooltips
• Legends
40
chart.xsp
41© 2011 IBM Corporation
29. How to show images
• Add Dojo resource:
• dojox.image.Lightbox
• Add Stylesheet
• /.ibmxspres/dojoroot/dojox/image/resources/Lightbox.css
• Build <a> tags with dojoType of dojox.image.Lightbox
and then enable ParseOnLoad
41
lightbox.xsp
42© 2011 IBM Corporation
30. How to use jQuery
• Use when you want to make use of a
jQuery plugin
• Import the jQuery library into the database
design as a file resource
• Everything else works as you would
expect with jQuery
• A good example is the Full Calendar
Plugin http://arshaw.com/fullcalendar/
42
jquery.xsp
43© 2011 IBM Corporation
Questions?
• Contact Us:
• Matt White
• matt.white@elguji.com
• twitter.com/mattwhite
• mattwhite.me
• Tim Clark
• tim_clark@uk.ibm.com
• twitter.com/timsterc
• blog.tc-soft.com
43
44© 2011 IBM Corporation 44
Legal Disclaimer
© IBM Corporation 2011. All Rights Reserved.
The information contained in this publication is provided for informational purposes only. While efforts were made to verify the completeness and accuracy of the information contained in this publication, it is provided AS
IS without warranty of any kind, express or implied. In addition, this information is based on IBM’s current product plans and strategy, which are subject to change by IBM without notice. IBM shall not be responsible for
any damages arising out of the use of, or otherwise related to, this publication or any other materials. Nothing contained in this publication is intended to, nor shall have the effect of, creating any warranties or
representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software.
References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. Product release dates and/or capabilities referenced in this
presentation may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. Nothing
contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results.
IBM, the IBM logo, Lotus, Lotus Notes, Notes, Domino, WebSphere and Lotusphere are trademarks of International Business Machines Corporation in the United States, other countries, or both. Unyte is a trademark of
WebDialogs, Inc., in the United States, other countries, or both.
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.
Other company, product, or service names may be trademarks or service marks of others.
Other company, product, or service names may be trademarks or service marks of others.

Mais conteúdo relacionado

Mais procurados

ASP.NET 4.0
ASP.NET 4.0ASP.NET 4.0
ASP.NET 4.0
XeDotNet
 
Developing html5 mobile applications using cold fusion 11
Developing html5 mobile applications using cold fusion 11Developing html5 mobile applications using cold fusion 11
Developing html5 mobile applications using cold fusion 11
ColdFusionConference
 
Asynchronous reading and writing http r equest
Asynchronous reading and writing http r equestAsynchronous reading and writing http r equest
Asynchronous reading and writing http r equest
Pragyanshis Patnaik
 

Mais procurados (19)

IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and ScalabilityIBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
 
TestComplete 7.50 New Features
TestComplete 7.50 New FeaturesTestComplete 7.50 New Features
TestComplete 7.50 New Features
 
Selenium - Installation
Selenium - InstallationSelenium - Installation
Selenium - Installation
 
Selenium Installation
Selenium  InstallationSelenium  Installation
Selenium Installation
 
ATG - Installing WebLogic Server
ATG - Installing WebLogic ServerATG - Installing WebLogic Server
ATG - Installing WebLogic Server
 
DBAdapters
DBAdaptersDBAdapters
DBAdapters
 
Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...
 
ASP.NET 4.0
ASP.NET 4.0ASP.NET 4.0
ASP.NET 4.0
 
Cfml features modern_coding
Cfml features modern_codingCfml features modern_coding
Cfml features modern_coding
 
Taking Advantage of Microsoft PowerShell
Taking Advantage of Microsoft PowerShell Taking Advantage of Microsoft PowerShell
Taking Advantage of Microsoft PowerShell
 
Hidden Gems in ColdFusion 11
Hidden Gems in ColdFusion 11Hidden Gems in ColdFusion 11
Hidden Gems in ColdFusion 11
 
Sql Server & PowerShell
Sql Server & PowerShellSql Server & PowerShell
Sql Server & PowerShell
 
Hidden Gems in ColdFusion 2016
Hidden Gems in ColdFusion 2016Hidden Gems in ColdFusion 2016
Hidden Gems in ColdFusion 2016
 
Developing html5 mobile applications using cold fusion 11
Developing html5 mobile applications using cold fusion 11Developing html5 mobile applications using cold fusion 11
Developing html5 mobile applications using cold fusion 11
 
Mongo db rev001.
Mongo db rev001.Mongo db rev001.
Mongo db rev001.
 
Testing soap UI
Testing soap UITesting soap UI
Testing soap UI
 
Exbrowser command-reference
Exbrowser command-referenceExbrowser command-reference
Exbrowser command-reference
 
Team foundation server
Team foundation serverTeam foundation server
Team foundation server
 
Asynchronous reading and writing http r equest
Asynchronous reading and writing http r equestAsynchronous reading and writing http r equest
Asynchronous reading and writing http r equest
 

Destaque (11)

Xullo 2013
Xullo 2013Xullo 2013
Xullo 2013
 
Estrategia de Social Media por Clara Soler - XpertoCM Murcia
Estrategia de Social Media por Clara Soler - XpertoCM MurciaEstrategia de Social Media por Clara Soler - XpertoCM Murcia
Estrategia de Social Media por Clara Soler - XpertoCM Murcia
 
XVII FESTIVAL INTERNACIONAL DE ARTES ESCÉNICAS PARA NIÑOS Y JÓVENES TEATRALIA
XVII FESTIVAL INTERNACIONAL DE ARTES ESCÉNICAS PARA NIÑOS Y JÓVENES TEATRALIAXVII FESTIVAL INTERNACIONAL DE ARTES ESCÉNICAS PARA NIÑOS Y JÓVENES TEATRALIA
XVII FESTIVAL INTERNACIONAL DE ARTES ESCÉNICAS PARA NIÑOS Y JÓVENES TEATRALIA
 
Научный конгресс "Психология XXI столетия" (Новосибирск, сентябрь 2013)
Научный конгресс "Психология XXI столетия" (Новосибирск, сентябрь 2013)Научный конгресс "Психология XXI столетия" (Новосибирск, сентябрь 2013)
Научный конгресс "Психология XXI столетия" (Новосибирск, сентябрь 2013)
 
X petras+new+7+wonders+of+the+world+
X petras+new+7+wonders+of+the+world+X petras+new+7+wonders+of+the+world+
X petras+new+7+wonders+of+the+world+
 
X men v4 021 - unknown
X men v4 021 - unknownX men v4 021 - unknown
X men v4 021 - unknown
 
XperiEIC Flyer
XperiEIC FlyerXperiEIC Flyer
XperiEIC Flyer
 
XPM – Gestión de Proyectos 2.0
XPM – Gestión de Proyectos 2.0XPM – Gestión de Proyectos 2.0
XPM – Gestión de Proyectos 2.0
 
XX lecie prezentacja
XX lecie prezentacjaXX lecie prezentacja
XX lecie prezentacja
 
xovy3.pptx
xovy3.pptxxovy3.pptx
xovy3.pptx
 
Xp delivery
Xp deliveryXp delivery
Xp delivery
 

Semelhante a XPages Blast - Lotusphere 2011

The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOC
Carl Lu
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
Ulrich Krause
 
WebLogic JMX for DevOps
WebLogic JMX for DevOpsWebLogic JMX for DevOps
WebLogic JMX for DevOps
Frank Munz
 
PowerShell for the Anxious ITPro
PowerShell for the Anxious ITProPowerShell for the Anxious ITPro
PowerShell for the Anxious ITPro
Jason Himmelstein
 

Semelhante a XPages Blast - Lotusphere 2011 (20)

XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
 
XPages Blast - Lotusphere 2012
XPages Blast - Lotusphere 2012XPages Blast - Lotusphere 2012
XPages Blast - Lotusphere 2012
 
Extension Library - Viagra for XPages
Extension Library - Viagra for XPagesExtension Library - Viagra for XPages
Extension Library - Viagra for XPages
 
XPages on Bluemix - the Do's and Dont's
XPages on Bluemix - the Do's and Dont'sXPages on Bluemix - the Do's and Dont's
XPages on Bluemix - the Do's and Dont's
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOC
 
A 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developersA 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developers
 
Icon UK 2018 - Spring forward: an introduction to Spring boot and Thymeleaf f...
Icon UK 2018 - Spring forward: an introduction to Spring boot and Thymeleaf f...Icon UK 2018 - Spring forward: an introduction to Spring boot and Thymeleaf f...
Icon UK 2018 - Spring forward: an introduction to Spring boot and Thymeleaf f...
 
KACE Agent Architecture and Troubleshooting Overview
KACE Agent Architecture and Troubleshooting OverviewKACE Agent Architecture and Troubleshooting Overview
KACE Agent Architecture and Troubleshooting Overview
 
Tips for Developing and Testing IBM HATS Applications
Tips for Developing and Testing IBM HATS ApplicationsTips for Developing and Testing IBM HATS Applications
Tips for Developing and Testing IBM HATS Applications
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino api
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
AIR - Framework ( Cairngorm and Parsley )
AIR - Framework ( Cairngorm and Parsley )AIR - Framework ( Cairngorm and Parsley )
AIR - Framework ( Cairngorm and Parsley )
 
Advanced Coded UI Testing
Advanced Coded UI TestingAdvanced Coded UI Testing
Advanced Coded UI Testing
 
Practical solutions for connections administrators lite
Practical solutions for connections administrators litePractical solutions for connections administrators lite
Practical solutions for connections administrators lite
 
WebLogic JMX for DevOps
WebLogic JMX for DevOpsWebLogic JMX for DevOps
WebLogic JMX for DevOps
 
PowerShell for the Anxious ITPro
PowerShell for the Anxious ITProPowerShell for the Anxious ITPro
PowerShell for the Anxious ITPro
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
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...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

XPages Blast - Lotusphere 2011

  • 1. © 2011 IBM Corporation BP211 XPages Blast Matt White | Lead Developer | Elguji Software Tim Clark | Tech Sales | IBM Lotus
  • 2. 2© 2011 IBM Corporation Matt White • Lead Developer at • Creators of IdeaJam™ and IQJam™ • Creator of XPages101.net • Founder member of the LDC 2
  • 3. 3© 2011 IBM Corporation Tim Clark • 17 years in IBM® Lotus® • Support, Sales and Channel • Creator of the X Cast, XPages podcast • http://www.thexcast.net 3
  • 4. 4© 2011 IBM Corporation Products we’re using • IBM® Lotus Domino® Server 8.5.2 • Most of the session is based on 8.5.2, where we use earlier versions we’ll mention it • IBM® Lotus Notes® 8.5.2 • IBM® Lotus Domino Designer® 8.5.2 4
  • 5. 5© 2011 IBM Corporation Agenda • General Programming Tips • Debugging • UI • Notes Client • Dojo 5
  • 6. 6© 2011 IBM Corporation Tip Grading • Beginner • Intermediate • Advanced 6
  • 7. 7© 2011 IBM Corporation Sample Database • You can download a database which demonstrates a lot of tips we talk about here: http://tinyurl.com/ls11xpagesblast 7
  • 8. 8© 2011 IBM Corporation General Programming Tips • Those useful bits and pieces that make your coding day fly by! 8
  • 9. 9© 2011 IBM Corporation 1. Scoped Variables • applicationScope • use to store data for all users of the app • sessionScope • use to store data for the current user • viewScope • use to store data for the current page • requestScope • use to store data for a single round trip to the server 9 scopedvariables.xsp
  • 10. 10© 2011 IBM Corporation 2. Repeat ANY data • Repeat controls can be used with any type of data, not just view data. • As long as the data is a list of some sort and you know how to reference it • @Functions can return a string or a list, to make sure the results work, use this $A function: • http://tinyurl.com/xpbrepeats 10 repeats.xsp
  • 11. 11© 2011 IBM Corporation 3. Calling an Agent in 8.5.0 or 8.5.1 • Don’t do it unless you really need to! • Running code as a different user (e.g. an admin) • You’ll probably end up having to save the document twice, so it’s very expensive. • However, if you really have to... var agent:NotesAgent = database.getAgent(“myagent”); agent.runOnServer(noteid); • Or you can always call an old style agent URL using AJAX (we’ll show you how later on) 11
  • 12. 12© 2011 IBM Corporation 4. Calling an Agent in 8.5.2 + • In 8.5.2 you can call an agent and pass an “in memory” document to it: Agent.runWithDocumentContext(NotesDocument) • There are also three different types of session object available: • session - the current user’s session • sessionAsSigner - a session running as the XPage signer • sessionAsSignerWithFullAccess - a session running as the XPage signer giving full admin rights • Running SSJS is always going to be faster than calling an agent 12
  • 13. 13© 2011 IBM Corporation 5. ACLs in XPages • If not done, people may be able to create documents that you are not expecting • Go to All Properties > Data > ACL and add ACL settings • Settings can be made for: • Default • Anonymous • Individuals • Groups • Roles 13
  • 14. 14© 2011 IBM Corporation 6. #{id:mycontrol} • Used if you want to know what the id of the field will be at runtime • Use this syntax to identify a specific field: • Also works in reused controls 14 clientsidereferences.xsp
  • 15. 15© 2011 IBM Corporation 7. Calling SSJS in CSJS • If you want to pass server side data to the client side as the page loads you can use: #{javascript:myfunction()} • Returns the result of “myfunction” at runtime inside your CSJS 15 clientsidereferences.xsp
  • 16. 16© 2011 IBM Corporation • A free download from OpenNTF: http://extlib.openntf.org/ • Provides a whole bunch of extra controls for your XPages • Just needs a simple install on the server to enable to extra controls 16 8. Extension Library
  • 17. 17© 2011 IBM Corporation 9. Localisation • Easy to do • Turn it on • Pick which languages you want to support • Edit the translation files • You’re done. ;o) 17
  • 18. 18 • When you add the custom control to an XPage, the Custom Properties tab of the custom control contains the list of all of the different properties which you can set © 2011 IBM Corporation 10. Custom Properties • It’s very easy to pass data around different custom controls • In the Custom Control properties go to the Property Definition section • Add a new property for each setting • Can be any data type (e.g. String, Boolean, Document data etc) • Can have a default value if the property is not set when the custom control is used 18
  • 19. 19© 2011 IBM Corporation 11. Using Java classes • Great for network operations and other pre-rolled Java functionality • Create a “lib” folder using the package explorer • Import your .jar file • Refer to the full package structure or use “importPackage” importPackage(com.xpagesblast.demo); var text = getComponent("inputtext").getValue(); var speaker:SaySomething = new SaySomething(text); getComponent("out").setValue(speaker.whatDoYouSay()); 19 java.xsp
  • 20. 20© 2011 IBM Corporation 12. Using an XPage as a servlet • If you want to get the memory resident benefits of an XPage but don’t want to return HTML then... • Set the rendered property to False • In afterRenderResponse event return required data: try{ var exCon = facesContext.getExternalContext(); var writer = facesContext.getResponseWriter(); var response = exCon.getResponse(); response.setContentType("text/plain"); writer.write("Hello World"); writer.endDocument(); facesContext.responseComplete(); writer.close(); //Leave this line out in 8.5.2 }catch(e){ _dump(e); } 20 servlet.xsp
  • 21. 21© 2011 IBM Corporation 13. IgnoreRequestParams • Control individual document bindings on a single XPage • In All Properties > Data > Data > dominoDocument, set ignoreRequestParams to false • Then whatever default action you have defined for the document data binding will take precedence over the URL Parameters • Useful for blog comments 21 requestparams.xsp
  • 22. 22© 2011 IBM Corporation Debugging • Because although we never create bugs, sometimes more information is useful 22
  • 23. 23© 2011 IBM Corporation 14. Configure Firewall • A lot of local firewalls block ports on the local machine • You’re basically running a local IBM® Websphere® server on a port somewhere in the 30,000+ range • You will never see an error so it’s difficult to debug • Either disable the firewall or work out a rule which allows the server to run 23
  • 24. 24© 2011 IBM Corporation 15. Turn on debugging • In the Application properties, check the “Display XPages Runtime Error Page” box. • Then when there is an error in your code you’ll get a more useful message 24
  • 25. 25© 2011 IBM Corporation 25 Error Code Most Likely Cause 500 There’s an error in your code. Idiot ;-) 404 A typo in your URL. Remember the XPage name is case sensitive 403 Forbidden error, the signing ID doesn’t have rights to run XPages 302 Shows up a lot in server logs. It’s a redirection and can be ignored. 16. Common Error Messages
  • 26. 26© 2011 IBM Corporation 17. Use OpenLog • Download OpenLog from OpenNTF http://www.openntf.org/projects/pmt.nsf/ProjectLookup/OpenLog • Download TaskJam (which has the script library in) from OpenNTF • At the top of your SSJS import OpenLogXPages • Implement using log.logEvent("Clearing the Cache", SEVERITY_LOW, "serverSide", "resetApplicationScope", null); • or log.logError(“There was an error”, SEVERITY_HIGH, “Error Message”, “Error Number”, “Location”, “Method”, “Error Line”, document); 26
  • 27. 27© 2011 IBM Corporation 18. Use Firebug • The single most important debugging tool for XPages • Lets you inspect HTML, CSS and CSJS • Network operations and AJAX requests • Download from Tools in Firefox or http://getfirebug.com • In CSJS use dojo.console(“message”); 27
  • 28. 28© 2011 IBM Corporation User Interface • Because even though we’re programmers, the UI is important 28
  • 29. 29© 2011 IBM Corporation 19. Themes & Global Config • Want to set something once and have it used everywhere, use Themes • Can set; stylesheets, classes on elements or pick a skin dynamically using simple XML, for example: <theme> <resource> <content-type>text/css</content-type> <href>custom.css</href> </resource> <control> <name>InputField.RichText</name> <property mode="concat"> <name>styleClass</name> <value>domino-richtext xspInputFieldRichText</value> </property> </control> </theme> 29
  • 30. 30© 2011 IBM Corporation • OneUI - http://tinyurl.com/xpboneui • Download “XPages framework” from OpenNTF • Or use the OneUI control in the Extension Library • Blueprint - http://tinyurl.com/xpbblueprint • 960 Grid - http://tinyurl.com/xpb960grid • Doesn’t matter which one, just USE ONE!!!!! 30 20. Use a CSS Framework
  • 31. 31© 2011 IBM Corporation XPages in Notes Client • XPiNC 31
  • 32. 32© 2011 IBM Corporation • If manually building URLs for the Notes Client • In 8.5.1 you HAVE TO add the SessionID parameter: &SessionID=tclk48931240 • Error 503 with no other explanation if you don’t add it • It’s been fixed in 8.5.2 32 21. Use &SessionID
  • 33. 33© 2011 IBM Corporation 22. View Page Source • Toolbar button only available if Designer installed • Shows the source HTML of XPages in Notes client • Useful because the HTML in the Notes Client is not always the same as in a web browser 33
  • 34. 34© 2011 IBM Corporation 23. View Logs in Notes Client • From menu • Help, Support, View Trace • Where the print statement output from SSJS is displayed • SSJS output only, CSJS output is not visible in XPiNC 34
  • 35. 35© 2011 IBM Corporation 24. Difference in URLs • If you manually build URLs be aware that there are different structures between the Notes Client and the web browser: • Web Browser /directory/XPagesBlast.nsf/test.xsp • Notes Client /xsp/ServerName!!directory/XPagesBlast.nsf/test.xsp 35
  • 36. 36© 2011 IBM Corporation Dojo • Not the fight place! 36
  • 37. 37© 2011 IBM Corporation 25. Enable parseOnLoad • If you have Dojo widgets on your XPage then you should set this to true, to have them automatically initialize • Unless you want to manually initialise Dojo Elements yourself using Javascript 37
  • 38. 38© 2011 IBM Corporation 26. Dialog box • If you want to interact with the server from inside your dialog box. You have to work around a “feature”. • Best option is to use Jeremy Hodge’s approach: http://tinyurl.com/xpbdialog • Include CSJS Library in your XPage, then enable dojoParseOnLoad and dojoTheme “feature” = BUG 38 dialog.xsp
  • 39. 39© 2011 IBM Corporation 27. Dojo Ajax Request • Writing your own Ajax can still be useful, simply use the xhr API: 39 ajax.xsp
  • 40. 40© 2011 IBM Corporation 28. Charting • dojox.charting offers a huge array of charting options • For a simple pie chart • import the basic modules • add the data (formatted as JSON) • add CSJS to initialize the chart • No flash required • offers animation • Tooltips • Legends 40 chart.xsp
  • 41. 41© 2011 IBM Corporation 29. How to show images • Add Dojo resource: • dojox.image.Lightbox • Add Stylesheet • /.ibmxspres/dojoroot/dojox/image/resources/Lightbox.css • Build <a> tags with dojoType of dojox.image.Lightbox and then enable ParseOnLoad 41 lightbox.xsp
  • 42. 42© 2011 IBM Corporation 30. How to use jQuery • Use when you want to make use of a jQuery plugin • Import the jQuery library into the database design as a file resource • Everything else works as you would expect with jQuery • A good example is the Full Calendar Plugin http://arshaw.com/fullcalendar/ 42 jquery.xsp
  • 43. 43© 2011 IBM Corporation Questions? • Contact Us: • Matt White • matt.white@elguji.com • twitter.com/mattwhite • mattwhite.me • Tim Clark • tim_clark@uk.ibm.com • twitter.com/timsterc • blog.tc-soft.com 43
  • 44. 44© 2011 IBM Corporation 44 Legal Disclaimer © IBM Corporation 2011. All Rights Reserved. The information contained in this publication is provided for informational purposes only. While efforts were made to verify the completeness and accuracy of the information contained in this publication, it is provided AS IS without warranty of any kind, express or implied. In addition, this information is based on IBM’s current product plans and strategy, which are subject to change by IBM without notice. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this publication or any other materials. Nothing contained in this publication is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. Product release dates and/or capabilities referenced in this presentation may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. Nothing contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results. IBM, the IBM logo, Lotus, Lotus Notes, Notes, Domino, WebSphere and Lotusphere are trademarks of International Business Machines Corporation in the United States, other countries, or both. Unyte is a trademark of WebDialogs, Inc., in the United States, other countries, or both. Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Other company, product, or service names may be trademarks or service marks of others. Other company, product, or service names may be trademarks or service marks of others.