• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Supersize me
 

Supersize me

on

  • 1,468 views

 

Statistics

Views

Total Views
1,468
Views on SlideShare
1,468
Embed Views
0

Actions

Likes
0
Downloads
10
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Supersize me Supersize me Presentation Transcript

    • “ Supersize Me !” - How I grew from a mere Lotuscript developer to become an XPager Peter May Domino Notes Applications Manchester May 2011
    • Agenda
      • 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.
    • Background
      • 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
    • The Project
      • Order processing
      • Travel Requests
      • Timesheet approval
      • Customer Invoicing
      • Oracle Financials
      • IT Factory databases
      • GMs use iPads
    • Extension Library Prototype
    • Help Grandpa Paul !
      • XPages Bootcamp
      • Copenhagen 2010
      • Paul & Russ for 3 days
      • Don't start with a major project
      • Cut your teeth on something small !!
    • 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 XPages
    • 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]');
    • Demo
      • 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
    • Key Challenges
      • Sending a link to a document in another db
      • Dynamic Column Totals in Views & Repeat Controls
      • Memory management in XPages
      • Exporting to Excel
      • SSJS creation of PDF with iText
      • Download control from a different database
      • Simple iPad Support
      • Error Handling
    • 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;;
    • Firebug to view the Source
    • 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
    • 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>
    • 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); }
    • 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();
    • 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 . . .
    • 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();
    • PDF Generation via iText
      • Download and install the iText jar file
      • Use Symphony to create your PDF template.
      • Write a SSJS function to create the PDF using this template.
      Window Show Eclipse Views Other Package Explorer
    • 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);
    • 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);
    • 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);
    • 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);
    • 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);
    • 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();
    • 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
    • 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
    • Things to take away
      • Almost everything you know still applies
      • Javascript is case-Sensitive
      • Brackets are required ()
      • You're not on your own
      • Come to Lotusphere
      • Have confidence in yourself