“ Supersize Me !”   - How I grew from a mere Lotuscript developer to become an XPager Peter May Domino Notes Applications ...
Agenda <ul><li>XPages project - from email to delivery
How the pain was eased
A brief overview of the application (Demo)
How some key challenges were solved
Things to take away. </li></ul>
Background <ul><li>Fortran programmer on punch-cards at 16
Second group in Oz with Comp. Sci. (Hons)
A choice between IBM & Rio Tinto
Became a consultant in 1998
Notes Developer since 4.0
Advanced certification in 5, 6, 7, & 8 </li></ul>
The Project <ul><li>Order processing
Travel Requests
Timesheet approval
Customer Invoicing
Oracle Financials
IT Factory databases
GMs use iPads </li></ul>
Extension Library Prototype
Help Grandpa Paul ! <ul><li>XPages Bootcamp
Copenhagen 2010
Paul & Russ for 3 days </li></ul><ul><li>Don't start with a major project
Cut your teeth on something small !! </li></ul>
Where to start
The best place to start - XPages.info
 
Project Databases Travel Request & Monthly Reports Open Log Archive Orders Invoices Customers Staff Projects Timesheets XP...
Scope Variables  (beforePageLoad event) synchronized(applicationScope){ if (!applicationScope.containsKey(&quot;staffDbNam...
Demo
<ul>Proposal Workflow </ul><ul>Owner Creates new Proposal </ul><ul>Sales cycle – owner prepares quote </ul><ul>Ready to Se...
Key Challenges <ul><li>Sending a link to a document in another db
Upcoming SlideShare
Loading in...5
×

Supersize me

1,238

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,238
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Supersize me

  1. 1. “ Supersize Me !” - How I grew from a mere Lotuscript developer to become an XPager Peter May Domino Notes Applications Manchester May 2011
  2. 2. Agenda <ul><li>XPages project - from email to delivery
  3. 3. How the pain was eased
  4. 4. A brief overview of the application (Demo)
  5. 5. How some key challenges were solved
  6. 6. Things to take away. </li></ul>
  7. 7. Background <ul><li>Fortran programmer on punch-cards at 16
  8. 8. Second group in Oz with Comp. Sci. (Hons)
  9. 9. A choice between IBM & Rio Tinto
  10. 10. Became a consultant in 1998
  11. 11. Notes Developer since 4.0
  12. 12. Advanced certification in 5, 6, 7, & 8 </li></ul>
  13. 13. The Project <ul><li>Order processing
  14. 14. Travel Requests
  15. 15. Timesheet approval
  16. 16. Customer Invoicing
  17. 17. Oracle Financials
  18. 18. IT Factory databases
  19. 19. GMs use iPads </li></ul>
  20. 20. Extension Library Prototype
  21. 21. Help Grandpa Paul ! <ul><li>XPages Bootcamp
  22. 22. Copenhagen 2010
  23. 23. Paul & Russ for 3 days </li></ul><ul><li>Don't start with a major project
  24. 24. Cut your teeth on something small !! </li></ul>
  25. 25. Where to start
  26. 26. The best place to start - XPages.info
  27. 28. Project Databases Travel Request & Monthly Reports Open Log Archive Orders Invoices Customers Staff Projects Timesheets XPages
  28. 29. Scope Variables (beforePageLoad event) synchronized(applicationScope){ if (!applicationScope.containsKey(&quot;staffDbName&quot;)) { var pDoc:NotesDocument = database.getProfileDocument (&quot;profile_AppConfig&quot;,&quot;&quot;); if (pDoc) { applicationScope.staffDbName = pDoc.getItemValueString (&quot;cfg_StaffDbName&quot;); applicationScope.ordersDbName = pDoc.getItemValueString (&quot;cfg_OrdersDbName&quot;); }}} sessionScope.isAdmin = context.getUser().getRoles(). contains('[TravelManager]');
  29. 30. Demo
  30. 31. <ul>Proposal Workflow </ul><ul>Owner Creates new Proposal </ul><ul>Sales cycle – owner prepares quote </ul><ul>Ready to Send </ul><ul>Are rates within acceptable limits? </ul><ul>Business and Commercial Manager reviews rates </ul><ul>BCM Reject </ul><ul>BCM Approve </ul><ul>GM reviews proposal </ul><ul>GM Reject </ul><ul>GM Approve </ul><ul>CEO reviews proposal </ul><ul>CEO Reject </ul><ul>CEO Approve </ul><ul>Is value under 150k? </ul><ul>Send proposal to client(s) </ul><ul>Cancel Proposal </ul><ul>Cancel Proposal </ul><ul>Proposal is closed (with reason) </ul><ul>Client Requests Revision </ul><ul>Client Accepts </ul><ul>Delivery – track projects and invoice clients </ul><ul>Completed - Close </ul><ul>No </ul><ul>No </ul><ul>Yes </ul><ul>Yes </ul><ul>Status = Pipeline Assignee = Owner </ul><ul>Status = GM Review Assignee = GM </ul><ul>Status = BCM Review Assignee = BCM </ul><ul>Status = CEO Review Assignee = CEO </ul><ul>Status = Offered Assignee = Owner </ul><ul>Status = Booked Assignee = Owner </ul><ul>Status = Closed Not Assigned </ul><ul>Finance Require Revision </ul>
  31. 32. Key Challenges <ul><li>Sending a link to a document in another db
  32. 33. Dynamic Column Totals in Views & Repeat Controls
  33. 34. Memory management in XPages
  34. 35. Exporting to Excel
  35. 36. SSJS creation of PDF with iText
  36. 37. Download control from a different database
  37. 38. Simple iPad Support
  38. 39. Error Handling </li></ul>
  39. 40. Email a doclink SSJS var body = memo.createMIMEEntity(); var stream = session.createStream(); stream.writeText(info); body.setContentFromText(stream, &quot;text/html; charset=iso-8859-1&quot;, 0); var info = msg + &quot;<br /><br /> <a href=' &quot; +applicationScope.surl + &quot;/apps/travelrequests.nsf/ xProposal.xsp?databaseName= &quot;+applicationScope.linkServer+&quot;!!&quot;+ applicationScope.proposalsDbName+&quot; &documentId= &quot;+ doc.getUniversalID()+&quot; &action=openDocument &content= docs_form '> Open Link </a> &quot;;
  40. 41. Firebug to view the Source
  41. 42. var fcast = 0; var i = 0; var ids = &quot;#{id:comboBox1}&quot;.split(&quot;comboBox1&quot;)[0]; while (dojo.byId(ids+&quot;repeat1:&quot;+i+&quot;:inputText3&quot;)) { var it3= dojo.byId(ids+&quot;repeat1:&quot;+i+&quot;:inputText3&quot;).innerHTML; it3 = it3.replace(&quot;$&quot;,&quot;&quot;).replace(/,/gi,&quot;&quot;); fcast = fcast + parseFloat(it3); i++; } var tot1 = Math.round(fcast*Math.pow(10,2))/Math.pow(10,2); tot = formatCurrency(tot1); dojo.byId(ids+&quot;computedField1&quot;).innerHTML=&quot;$&quot;+tot; Dynamic column totals CSJS
  42. 43. Adding Totals to View Columns <xp:viewPanel rows=&quot;100&quot; id=&quot;viewPanel1&quot; var=&quot;rowData&quot;> <xp:this.facets> <xp:panel xp:key=&quot;footer&quot; id=&quot;totals1&quot;> <xp:tr> <xp:td colspan=&quot;7&quot;></xp:td> <xp:td> <xp:text escape=&quot;true&quot; id=&quot;computedField1&quot;> </xp:td> </xp:tr> </xp:panel> </xp:this.facets>
  43. 44. Memory Management in XPages var dc:NotesDocumentCollection = doc.getResponses(); var rdoc:NotesDocument = dc.getFirstDocument(); while (rdoc) { //do something with rdoc var nextdoc:NotesDocument = dc.getNextDocument (rdoc); rdoc.recycle(); var rdoc = nextdoc; } dc.recycle(); rdoc = dc.getNextDocument(rdoc); }
  44. 45. Export to Excel <ul><li>Button CSJS: </li></ul>document.location = &quot;xExportToExcel.xsp?p1=&quot;+ parameter1+&quot;&p2=&quot;+parameter2 <ul><li>XPage: with rendered=”false” </li></ul>afterRenderResponse event calls SSJS function <ul><li>function writeViewToBrowser(); </li></ul>
  45. 46. Export to Excel - SSJS var exCon = facesContext.getExternalContext(); var writer = facesContext.getResponseWriter(); var response = exCon.getResponse(); response.setContentType(&quot;application/csv-tab-delimited-table;charset=utf-8&quot;); response.setHeader(&quot;Cache-Control&quot;, &quot;no-cache&quot;); response.setHeader(&quot;Content-Disposition&quot;, &quot;attachment; filename=&quot;export.xls&quot;&quot;); continued . . .
  46. 47. Excel Export (SSJS cont.) s = &quot;<html><head><meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot;/></head> <body><table><tr>&quot;; writer.write(s+&quot;n&quot;); [put your html here] s = &quot;</tr></table></body></html>&quot;; writer.write(s); writer.endDocument();
  47. 48. PDF Generation via iText <ul><li>Download and install the iText jar file </li></ul><ul><li>Use Symphony to create your PDF template.
  48. 49. Write a SSJS function to create the PDF using this template. </li></ul>Window Show Eclipse Views Other Package Explorer
  49. 50. SSJS function for PDF generation //1. Load the java packages importPackage(com.itextpdf); importPackage(com.itextpdf.text); importPackage(com.itextpdf.text.pdf); importPackage(com.itextpdf.text.pdf.fonts); importPackage(java.io);
  50. 51. 2. Initialise & get the template var theDirectory= session.getEnvironmentString(&quot;Directory&quot;,true); var reader = new com.itextpdf.text.pdf.PdfReader (theDirectory + &quot;/TaxInvoice.pdf&quot;); var fileOut = new java.io.FileOutputStream(filename); var stamper = new com.itextpdf.text.pdf.PdfStamper(reader, fileOut); var canvas = stamper.getOverContent(1);
  51. 52. 3. Embed your fonts var arial = new BaseFont.createFont(&quot;c:/windows/fonts/arial.ttf&quot;, BaseFont.WINANSI, BaseFont.EMBEDDED); var arialbd = new BaseFont.createFont(&quot;c:/windows/fonts/arialbd.ttf&quot;, BaseFont.WINANSI, BaseFont.EMBEDDED); var NORMAL = new Font(arial,10); var BOLD = new Font(arialbd,10); var BOLD11 = new Font(arialbd,11); var BOLD12 = new Font(arialbd,12);
  52. 53. 4. Create and place your data var client = new Phrase(doc.getItemValueString(&quot;Client&quot;),NORMAL); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, client, 65, 670, 0); var lcost = new Phrase(@Text(resp.getItemValueDouble(&quot;Cost&quot;),&quot;C,&quot;), BOLD11); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, lcost, 563, 533 - (i*44), 0);
  53. 54. 5.Close and attach stamper.close(); fileOut.close(); //attach the pdf var rtitem:NotesRichTextItem= doc.createRichTextItem(&quot;Invoice&quot;); rtitem.embedObject(NotesEmbeddedObject.EMBED_ATTACHMENT, &quot;&quot;, filename, null);
  54. 55. Download Control fix var serv = session.getHttpURL().split(&quot;?&quot;)[0]; if (!@IsNewDoc()) {return serv + &quot;/&quot; + sessionScope.invoiceDbName+ &quot;/0/&quot; + document1.getDocument().getUniversalID() + &quot;$FILE/&quot;+ rowData.getName(); } else {return &quot;#&quot;;} if (@ClientType()==&quot;Notes&quot;) return &quot;/.ibmmodres/&quot; + &quot;domino/OpenAttachment/&quot;+ database.getServer() + &quot;!!&quot;+sessionScope.invoiceDbName + &quot;/&quot;+document1.getDocument().getUniversalID() + &quot;/attachment/&quot;+rowData.getName();
  55. 56. Meta tags for iPhone/iPad <meta name=&quot;viewport&quot; content=&quot;width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;&quot; /> <meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot; /> Mark Hughes: www-10.lotus.com/ldd/ddwiki.nsf/dx/X-Pages_iPhone_ Application_Tutorial
  56. 57. Use of OpenLog for Error Handling import OpenLogXPages; function createAuditRecord() { try { //<some code to run> } catch(e) { requestScope.errMessage = &quot;Error: &quot; + e.toString(); msg = &quot;createAuditRecord Error: &quot; + e.toString(); log.logError(msg, SEVERITY_HIGH, e.toString(), null, &quot;serverSide&quot;, &quot;createAuditRecord&quot;, null, doc); } } Julian Robichaux & Rob McDonagh
  57. 58. Things to take away <ul><li>Almost everything you know still applies
  58. 59. Javascript is case-Sensitive
  59. 60. Brackets are required ()
  60. 61. You're not on your own
  61. 62. Come to Lotusphere
  62. 63. Have confidence in yourself </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×