Your SlideShare is downloading. ×
Supersize me
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Supersize me

1,167
views

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,167
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
11
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. “ Supersize Me !” - How I grew from a mere Lotuscript developer to become an XPager Peter May Domino Notes Applications Manchester May 2011
  • 2. Agenda
    • XPages project - from email to delivery
    • 3. How the pain was eased
    • 4. A brief overview of the application (Demo)
    • 5. How some key challenges were solved
    • 6. Things to take away.
  • 7. Background
    • Fortran programmer on punch-cards at 16
    • 8. Second group in Oz with Comp. Sci. (Hons)
    • 9. A choice between IBM & Rio Tinto
    • 10. Became a consultant in 1998
    • 11. Notes Developer since 4.0
    • 12. Advanced certification in 5, 6, 7, & 8
  • 13. The Project
  • 20. Extension Library Prototype
  • 21. Help Grandpa Paul !
    • XPages Bootcamp
    • 22. Copenhagen 2010
    • 23. Paul & Russ for 3 days
    • Don't start with a major project
    • 24. Cut your teeth on something small !!
  • 25. Where to start
  • 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
  • 29. Scope Variables (beforePageLoad event) synchronized(applicationScope){ if (!applicationScope.containsKey("staffDbName")) { var pDoc:NotesDocument = database.getProfileDocument ("profile_AppConfig",""); if (pDoc) { applicationScope.staffDbName = pDoc.getItemValueString ("cfg_StaffDbName"); applicationScope.ordersDbName = pDoc.getItemValueString ("cfg_OrdersDbName"); }}} sessionScope.isAdmin = context.getUser().getRoles(). contains('[TravelManager]');
  • 30. Demo
  • 31.
      Proposal Workflow
      Owner Creates new Proposal
      Sales cycle – owner prepares quote
      Ready to Send
      Are rates within acceptable limits?
      Business and Commercial Manager reviews rates
      BCM Reject
      BCM Approve
      GM reviews proposal
      GM Reject
      GM Approve
      CEO reviews proposal
      CEO Reject
      CEO Approve
      Is value under 150k?
      Send proposal to client(s)
      Cancel Proposal
      Cancel Proposal
      Proposal is closed (with reason)
      Client Requests Revision
      Client Accepts
      Delivery – track projects and invoice clients
      Completed - Close
      No
      No
      Yes
      Yes
      Status = Pipeline Assignee = Owner
      Status = GM Review Assignee = GM
      Status = BCM Review Assignee = BCM
      Status = CEO Review Assignee = CEO
      Status = Offered Assignee = Owner
      Status = Booked Assignee = Owner
      Status = Closed Not Assigned
      Finance Require Revision
  • 32. Key Challenges
    • Sending a link to a document in another db
    • 33. Dynamic Column Totals in Views & Repeat Controls
    • 34. Memory management in XPages
    • 35. Exporting to Excel
    • 36. SSJS creation of PDF with iText
    • 37. Download control from a different database
    • 38. Simple iPad Support
    • 39. Error Handling
  • 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;;
  • 41. Firebug to view the Source
  • 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
  • 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>
  • 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); }
  • 45. Export to Excel
    • Button CSJS:
    document.location = &quot;xExportToExcel.xsp?p1=&quot;+ parameter1+&quot;&p2=&quot;+parameter2
    • XPage: with rendered=”false”
    afterRenderResponse event calls SSJS function
    • function writeViewToBrowser();
  • 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 . . .
  • 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();
  • 48. PDF Generation via iText
    • Download and install the iText jar file
    • Use Symphony to create your PDF template.
    • 49. Write a SSJS function to create the PDF using this template.
    Window Show Eclipse Views Other Package Explorer
  • 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);
  • 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);
  • 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);
  • 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);
  • 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);
  • 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();
  • 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
  • 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
  • 58. Things to take away
    • Almost everything you know still applies
    • 59. Javascript is case-Sensitive
    • 60. Brackets are required ()
    • 61. You're not on your own
    • 62. Come to Lotusphere
    • 63. Have confidence in yourself