John M. Wargo

Twitter Feed

johnwargo: Here we go - First-time smartphone buyers favor Android over iOS: http://t.co/mQwxRHDP
johnwargo: Ummm, eating a handful of Dark Chocolate M&M's So good!
johnwargo: Working on the book's preface, hard 2 keep myself from saying 'the book you hold in your hand' since many won't ever actually hold the book
johnwargo: When sending an email to a group, why is it that Lotus Notes is smart enough to not send me a copy if I'm in the group but Outlook isn't?
johnwargo: Staying at a hotel without a gym. Ugh. I didn't even think to check to see if they had one, assumed they did.
Home
Amazon's Silk Browser PDF Print E-mail
Sunday, 02 October 2011 17:52

I'm really stunned by the market's response to Amazon's announcement of their new ereader. Somehow people seem to think that the new Silk browser included with the device is something special - although much of what the Silk browser does is something the BlackBerry browser has done for years. What's the big deal?

 
Macintosh OS Developer Friendly Tools PDF Print E-mail
Sunday, 11 September 2011 12:42

As I work through the chapters of my forthcoming book on PhoneGap, I’m working on both a Macintosh and PC which reminds me of first years of my professional career. I was doing PC support for a PC dealer called Basicomputer and always had a IBM PC and a Macintosh on my desk plus even had an Apple II for a long time as well (it was an Apple IIgs).

Anyway, as I’m writing about installing the PhoneGap software for Android and iOS development I found myself in need of installing Ant and Java on my Macintosh. As I poked and prodded around on the Internet I was struggling to find the information I needed about installing those two tools on Mac OS. It was really frustrating and I couldn’t figure out why nobody had written about the topic when I discovered by accident that the Macintosh installs Ant and Java by default. Nice!

On my new Mac Mini running OS X Lion, Java isn’t installed, but installs itself when you first try to run a Java application. That’s pretty cool. Ant’s installed and even on my Macbook (running snow leopard) the latest version is on there already.

Of course, all those long time Mac users (I used to be one, but switched to PC a long time ago – I may switch back) already know this, but why would they not write documentation applicable for people first picking up a Macintosh? The difference between my writing and the writing of others is that I try very hard to assume VERY LITTLE. I wish others would do the same.

 
A New RESTful Service PDF Print E-mail
User Rating: / 1
PoorBest 
Wednesday, 07 September 2011 07:24

I have published several articles on this site that illustrated different types of web services for Domino that I have used in some mobile applications. Domino easily supports XML-based web services and platforms such as BlackBerry and Windows Mobile have inherent capabilities that allow applications to consume XML-based web services. Other platforms on the other hand don’t have built-in support for XML-based web services, so I’ve had to implement RESTful services for applications built for other platforms such as Android and iOS. More recently I’ve decided to make a change to the RESTful agent I’ve been using for my applications and thought I’d document the changes here.

With my original web services, the idea was that a mobile application would send a request for a list of contacts that matched a search string then, when an application user selected a user, the application would make another call to the server to obtain the details for the selected contact. This process is illustrated in Figure 1.

Figure 1 – Two-part Request Process

When I first started doing mobile development, performance was important. The networks were slow and mobile devices had limited processing power, memory and battery life. In order to make the most efficient use of the network and increase performance and battery life for the device, I built the services to make the best use of network and processing power. What this meant was that the services would be designed to send a little data as possible over the wireless network and to ensure that data that would possibly not be used by the mobile application wouldn’t be sent across the wireless network.

So, in my design, I deliberately built the services so the first request simply retrieved a list of contacts that matched the search string then allowed the application to get detailed contact information only after they determined which contact they were interested in.

It seemed like a good approach and has served me rather well. The problem with this approach though is that it makes building the mobile application more difficult. There are two calls to the server and the results have to be parsed twice as well. If the mobile user selects one contact, then decides it’s the wrong one and switches to another, there’s another trip to the server for more data.

It’s efficient on the network, but inefficient within the application. The thing is, mobile users and mobile device manufacturers stopped caring about network usage and battery life a long time ago. Users want whatever they want and they want it now.

Apple’s Dashcode IDE has some pretty cool features that make it easy to work with remote data sets. When you build a Browser project using one of Dashcode’s wizards, the application expects a list of records and the details behind the list to all be delivered to the application at one time. The result is only one trip to the server, and a better user experience. There’s only one trip forth and back from the server which makes the user feel better, but we’re delivering data to the mobile device application that the user may never look at. Oh well.

So, I decided to rewrite my Domino Directory lookup agent so all of the relevant data could be retrieved with a single call to the RESTful agent as shown in Figure 2.

Figure 2 – Single Part Request Process

With this new service, a single call is made to the server using the following URL:

http://server/database.nsf/contactlookuprest?openagent&ss=SEARCH_STRING

where SEARCH_STRING represents the first three characters (or so) of the contact name the user will be searching for. As an example, a call to the server using the following URL:

http://server/database.nsf/contactlookuprest?openagent&ss=war


would return the following JSON data (or something like it):
[{"FullName":"Anna Wargo", "LastName":"Wargo", "FirstName":"Anna", "EmailAddress":"awargo@somecompany.com", "OfficePhone":"330.665.1234", "MobilePhone":"330.999.1234"}, {"FullName":"John Wargo", "LastName":"Wargo", "FirstName":"John", "EmailAddress":"john@johnwargo.com", "OfficePhone":"330.123.4567", "MobilePhone":"330.987.6543"}]


The JSON text returned from the server in this case is an array of JavaScript objects. If you expand the JSON text to show the structure of the data, the data will look like the following:
[
 {
 "FullName":"Anna Wargo",
 "LastName":"Wargo",
 "FirstName":"Anna",
 "EmailAddress":"awargo@somecompany.com",
 "OfficePhone":"330.665.1234",
 "MobilePhone":"330.999.1234"
 },
 {
 "FullName":"John Wargo",
 "LastName":"Wargo",
 "FirstName":"John",
 "EmailAddress":"john@johnwargo.com",
 "OfficePhone":"330.123.4567",
 "MobilePhone":"330.987.6543"
 }
]


I can use this data in my application by only pulling out the list of FullName values when presenting a list of contacts, then digging in and displaying the contact details only after a contact has been selected within the application.

The brackets (the ‘[‘ and ’]’ characters) are used to define an array and the curly braces ( the ‘{‘ and ‘}’ characters) are used to define a JavaScript object. So, what you’re seeing is a essentially a two element array, where each element is a complete JavaScript object describing contact details for a user defined in the Domino Directory database.

To obtain this output, all you need is a simple agent in a Domino Directory database. To create the RESTful service, create a new agent in your Domino Directory and set the agent properties shown in Figure 3. The agent is a web agent; it is triggered by a URL request triggered by the mobile application (or web browser). It uses an ‘On Event’ trigger and the event is defined as ‘Agent list selection.’

Figure 3 – Domino RESTful Agent Properties

Most of the agent’s work is done in the Initialize subroutine which performs the following steps:

1.    Parse the incoming URL to determine the search string being passed in by the calling program.
2.    Search the ($VIMPeopleByLastName) view to locate all users defined in the database whose last name begins with the characters provided in the search string.
3.    Loop through the search results and create the JSON array described previously.
4.    Print the JSON array text to the console which causes it to be returned to the program that triggered the URL.

In the code, the GetCmdLineValue function is used to parse the HTTP QUERY_STRING variable to retrieve values passed on the URL.

Here is the complete code for the agent:

%REM
 Agent ContactLookupREST
 Created Jan 13, 2010 by John M. Wargo
 Description: Modified the existing DomDirLookupREST agent
 so it returns the complete contact array rather than 
 forcing a developer to create a second call to the agent
 after the user selects a contact. This would send more
 data over the network, but will make a mobile application
 that calls it more responsive.
%END REM

Option Public
Option Declare
Option Base 1

'Notes Objects
Dim db As NotesDatabase

Sub Initialize()

 'Print out this line to force Domino to
 'not write it's own HTML gunk at the
 'beginning of the resulting page.
 Print "Content-Type:text/html"

 'some constants we'll need
 Const amp = |&|    
 Const BR = |<br />|
 Const comma = |,|
 Const errorStr = |"ERROR: |
 Const jsonArrayStart = "["
 Const jsonArrayEnd = "]"
 Const jsonObjectStart = |{|
 Const jsonObjectEnd = |}|
 Const quoteStr = |"|

 'Notes Objects
 Dim doc As NotesDocument
 Dim s As NotesSession
 Dim tmpName As NotesName
 Dim userView As NotesView
 Dim userDoc As NotesDocument
 Dim ve As NotesViewEntry
 Dim vec As NotesViewEntryCollection

 'Other variables
 Dim i As Integer
 Dim jsonText As String
 Dim numContacts As Integer
 Dim queryStr As String
 Dim searchStr As String

 'Initialize our Notes session object
 Set s = New NotesSession
 'Then get a handle to the current database
 Set db = s.CurrentDatabase
 'Get a handle to the agent's context 
 '(header variables and so on)
 Set doc = s.DocumentContext

 'Proper command line for the agent is:
 'http://servername/dbname/ContactLookupREST?openagent&ss=SEARCH_STRING
 queryStr = LCase(doc.Query_String_Decoded(0)) & amp
 searchStr = GetCmdLineValue(queryStr, "&ss=", amp)
 
 'Open the view we're going to lookup against
 Set userView = db.GetView("($VIMPeopleByLastName)")
 If Not userView Is Nothing Then
 'Do we have a search string?
 If Len(Trim(searchStr)) > 0 Then
 'See if we can find any users by the search string
 Set vec = userView.GetAllEntriesByKey(searchStr)
 Else
 'Otherwise get all documents
 Set vec = userView.AllEntries
 End If
 'Now, if we have any entries - put them into the array
 If vec.Count > 0 Then
 'Get the number of contacts to use throughout the 
 ' rest of the code
 numContacts = vec.Count
 'Start the Array JSON text
 jsonText = jsonArrayStart
 'Process all of the entries in the View Entry
 ' Collection
 For i = 1 To numContacts
 Set ve = vec.GetNthEntry(i)
 If Not ve Is Nothing Then
 Set userDoc = ve.Document
 If Not userDoc Is Nothing Then
 'Populate the result fields
 Set tmpName = New NotesName(userDoc.FullName(0))
 'Start the JSON text we'll be returning
 jsonText = jsonText & jsonObjectStart & _
 |"FullName":| & quoteStr & _ 
 tmpName.Abbreviated & _
 quoteStr & comma & _
 |"LastName":| &  quoteStr & _ 
 userDoc.LastName(0) & _
 quoteStr & comma & _
 |"FirstName":| &  quoteStr & _ 
 userDoc.FirstName(0) & _
 quoteStr & comma & _
 |"EmailAddress":| &  quoteStr & _ 
 userDoc.InternetAddress(0) & _
 quoteStr & comma & _
 |"OfficePhone":| & quoteStr & _ 
 userDoc.OfficePhoneNumber(0) & _
 quoteStr & comma & _
 |"MobilePhone":| &  quoteStr & _ 
 userDoc.CellPhoneNumber(0) & quoteStr & _
 jsonObjectEnd
 Else
 'Unable to get the document
 jsonText = jsonText & errorStr & _
 |Unable to open the contact document"|
 End If
 Else
 'Unable to access the View Entry
 jsonText = jsonText & errorStr & _
 |Unable to access the ViewEntry"|
 End If
 'Add a comma if we need one (when there's 
 ' more than one name being returned)
 If (i < numContacts) Then
 jsonText = jsonText & comma
 End If
 Next i
 'Write our resulting JSON results to the browser
 Print jsonText & jsonArrayEnd
 Else
 'We got nothing, so return an empty array to the 
 'calling program
 Print jsonArrayStart & jsonArrayEnd
 End If
 End If

End Sub

%REM
 Function GetCmdLineValue
 Description: Parses a string and returns 
 the value between two delimeters
%END REM
Function GetCmdLineValue( textStr As String, _
 delim1 As String, delim2 As String) As String

 Dim startPos As Integer
 Dim tmpInt As Integer
 Dim valLen As Integer

 'find the first ocurrance of the delimeter
 tmpInt = InStr( textStr, delim1)
 'Only continue if we've found something
 If (tmpInt > 0) Then
 'Figure out where the value starts 
 startPos =  tmpInt + Len(delim1)
 'Then look past there for the second delimeter
 valLen = InStr(startPos, textStr, delim2) - startPos
 'The value we're looking for is between the two delimeters
 GetCmdLineValue = Mid( textStr, startPos, valLen)
 Else
 GetCmdLineValue = ||
 End If 

End Function

After you’ve entered all of the code into the agent, be sure to test the results by pasting the service URL (using your own server and database values) into the desktop browser.

 
RIM Update PDF Print E-mail
Wednesday, 31 August 2011 09:32

Research In Motion made some interesting announcements yesterday.

First of all they announced that they’ve FINALLY launched a private beta for native development tools for the PlayBook. With the device announced more than a year ago and physical devices in the hands of users since May, you’d think a native SDK would have been made available a long time ago, but you’d be wrong.

Here’s the announcement: http://devblog.blackberry.com/2011/08/native-sdk-for-blackberry-tablet-os-closed-beta/

Google and Apple typically make their SDK’s available at device announcement or at least at device release, but Research In Motion has always been slower to market with their development tools. Now, in their defense, they had development tools for PlayBook available at device launch, both WebWorks and Adobe Air development options were available. So not having a native SDK wasn’t a big deal, but any game developer or someone building device drivers would suffer until now. It’s a closed beta, so that means public beta and final release are months away.

My only hope is that they can get this figured out before the new QNX-based devices become available supposedly next year.

The second announcement was from Mike Kirkup, Research In Motion’s long standing director of their Global Developer Relations team. Mike Announced on http://mikekirkup.com that he was resigning from his position at Research In Motion after 10 years with the company. This isn’t good news and it will be interesting to see who replaces him or what happens with the position. Mike’s team worked with all Research In Motion development partners, helping them bring commercial software products to market. I’m assuming they’ll continue with their work, but I wonder if Mike leaving is related to some fundamental change to how they will support developers and that’s why he’s leaving.

On (or about, I can’t remember) July 25th, Research In Motion made a huge reduction in it’s workforce. The biggest impact I’m aware of was to the US Carrier business units. When I worked at Research In Motion, I was part of the team supporting AT&T. With the reduction in force (RIF), RIM whacked from the AT&T business unit the entire Regional Technical Manager (RTM) team except for one person and as I understand it, cut the Regional Sales Team (RSM) in half. So, what was once a team of between 16 to 20 people is now a team of 5 people. Ouch.

What’s next I wonder?

 
<< Start < 1 2 3 4 5 6 8 10 > End >>

Page 8 of 51

InformIT (Pearson Education)