XPages Blast - ILUG 2010

  • 1,274 views
Uploaded on

30 top tips from 2010

30 top tips from 2010

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,274
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. XPages Blast 30 top tips in 60 minutes 1 1
  • 2. Matt WhiteLead Developer at Creators of IdeaJam and IQJamCreator of XPages101.net Use coupon code “ilug2010” for a 33% discountFounder member of the LDC 2 2
  • 3. Tim Clark16+ years in Lotus brand Support, Sales and ChannelCreator of the X Cast, XPages podcast http://bit.ly/ilugmo 3 3
  • 4. AgendaGeneral Programming TipsDebuggingUINotes ClientDojo 4 4
  • 5. Tip GradingBeginnerIntermediateAdvanced 5 5
  • 6. Sample DatabaseYou can download a database whichdemonstrates a lot of tips we talk about here:http://tinyurl.com/xpagesblast 6 6
  • 7. General Programming Tips Those useful bits and pieces that make your coding day fly by! 7 7
  • 8. 1. Scoped VariablesapplicationScope use to store data for all users of the appsessionScope use to store data for the current userviewScope use to store data for the current pagerequestScope use to store data for a single round trip to the server 8 scopedvariables.xsp 8
  • 9. 2. Repeat ANY dataRepeat controls can be used with any type ofdata, not just view data.As long as the data is a list of some sort and youknow how to reference it@Functions can return a string or a list, to makesure the results work, use this $A function: http://tinyurl.com/xpbrepeats 9 repeats.xsp 9
  • 10. 3. Calling a Notes 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) 10 10
  • 11. 4. Calling a Notes Agents 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 11 11
  • 12. 5. ACLs in XPagesIf not done, people may be able to create documents that you are notexpectingGo to All Properties > Data > ACL and add ACL settingsSettings can be made for: Default Anonymous Individuals Groups Roles 12 12
  • 13. 6. #{id:mycontrol}Used if you want to know what the id of the field willbe at runtimeUse this syntax to identify a specific field:Also works in reused controls 13 clientsidereferences.xsp 13
  • 14. 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 14 clientsidereferences.xsp 14
  • 15. 8. XPages Extension LibraryA free download from OpenNTF:http://extlib.openntf.org/Provides a whole bunch of extracontrols for your XPagesJust needs a simple install on theserver to enable to extra controls 15 15
  • 16. 9. LocalizationEasy to doTurn it onPick which languages youwant to supportEdit the translation filesYou’re done. ;o) 16 16
  • 17. 10. Using Java classesGreat for network operations and other pre-rolledJava functionalityCreate a “lib” folder using the package explorerImport your .jar fileRefer 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()); 17 java.xsp 17
  • 18. 11. Using an XPage as a servletIf you want to get the memory resident benefits of an XPage but don’t want to returnHTML then...Set the rendered property to FalseIn 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);} 18 servlet.xsp 18
  • 19. 12. 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 19 requestparams.xsp 19
  • 20. DebuggingBecause although we never create bugs,sometimes more information is useful 20 20
  • 21. 13. Configure FirewallA lot of local firewalls block ports on the localmachineYou’re basically running a local Websphere serveron a port somewhere in the 30,000+ rangeYou will never see an error so it’s difficult to debugEither disable the firewall or work out a rule whichallows the server to run 21 21
  • 22. 14. Turn on debuggingIn the Application properties, check the “Display XPagesRuntime Error Page” box.Then when there is an error in your code you’ll get a moreuseful message 22 22
  • 23. 15. Common Error MessagesError Code Most Likely Cause 500 There’s an error in your code. Idiot ;-) A typo in your URL. Remember the XPage 404 name is case sensitive Forbidden error, the signing ID doesn’t have 403 rights to run XPages Shows up a lot in server logs. It’s a 302 redirection and can be ignored. 23 23
  • 24. 16. Use OpenLogDownload OpenLog from OpenNTFhttp://www.openntf.org/projects/pmt.nsf/ProjectLookup/OpenLogDownload TaskJam (which has the script library in) fromOpenNTFAt the top of your SSJSimport OpenLogXPagesImplement usinglog.logEvent("Clearing the Cache", SEVERITY_LOW, "serverSide","resetApplicationScope", null);orlog.logError(“There was an error”, ! SEVERITY_HIGH, “Error Message”,“Error Number”, “Location”, “Method”, “Error Line”, document); 24 24
  • 25. 17. Use FirebugThe single most important debugging tool for XPages Lets you inspect HTML, CSS and CSJS Network operations and AJAX requestsDownload from Tools in Firefox orhttp://getfirebug.comIn CSJS usedojo.console(“message”); 25 25
  • 26. 18. Use MedusaA plugin for XPages developers to use inside Firebug Allows you to test SSJS code live Compare the HTML to the source XML of your XPageDownload from OpenNTFBuy Tim Tripcony, Nathan Freeman & Colin McDonald a drink nexttime you see them. 26 26
  • 27. User InterfaceBecause even though we’re programmers,the UI is important 27 27
  • 28. 19. Themes & Global ConfigWant to set something once and have it used everywhere, useThemesCan set; stylesheets, classes on elements or pick a skindynamically 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> 28 28
  • 29. 20. Use a CSS framework 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!!!!! 29 29
  • 30. XPages in Notes ClientXPiNC 30 30
  • 31. 21. Use &SessionIDIf manually building URLs for the Notes ClientIn 8.5.1 you HAVE TO add the SessionIDparameter:&SessionID=tclk48931240Error 503 with no other explanation if youdon’t add itIt’s been fixed in 8.5.2 31 31
  • 32. 22. View Page SourceToolbar button only available if DesignerinstalledShows the source HTML of XPages in NotesclientUseful because the HTML in the Notes Clientis not always the same as in a web browser 32 32
  • 33. 23. View Logs in Notes ClientFrom menuHelp, Support, View TraceWhere the print statement output from SSJS is displayedSSJS output only, CSJS output is not visible in XPiNC 33 33
  • 34. 24. Difference in URLsIf you manually build URLs be aware that thereare different structures between the Notes Clientand the web browser: Web Browser /directory/XPagesBlast.nsf/test.xsp Notes Client /xsp/ServerName!!directory/XPagesBlast.nsf/test.xsp 34 34
  • 35. DojoNot the fight place! 35 35
  • 36. 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 36 36
  • 37. 26. Dialog boxIf you want to interact with the server frominside your dialog box. You have to workaround a “feature”.Best option is to use Jeremy Hodge’sapproach: http://tinyurl.com/xpbdialogInclude CSJS Library in your XPage, thenenable dojoParseOnLoad and dojoTheme “feature” = BUG 37 dialog.xsp 37
  • 38. 27. Dojo Ajax RequestWriting your own Ajax can still be useful, simply use the xhrAPI: 38 ajax.xsp 38
  • 39. 28. Chartingdojox.charting offers a huge array of charting optionsFor a simple pie chart import the basic modules add the data (formatted as JSON) add CSJS to initialize the chartNo flash required offers animation Tooltips Legends 39 chart.xsp 39
  • 40. 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 40 lightbox.xsp 40
  • 41. 30. How to use jQueryUse when you want to make use ofa jQuery pluginImport the jQuery library into thedatabase design as a file resourceEverything else works as youwould expect with jQueryA good example is the FullCalendar Plugin http://arshaw.com/fullcalendar/ 41 jquery.xsp 41
  • 42. Questions? ?Matt White Tim Clarkmatt.white@elguji.com tim_clark@uk.ibm.com@mattwhite @timstercmattwhite.me blog.tc-soft.com 42 42