- Free PDF Library for Delphi Developers - Quick PDF Library LITE
- MSBuild and Delphi compiler hints – binary patch
- Join Embarcadero for Free Webinar on Delivering Reports Using FastReport and RAD Studio XE 2
- Delphi Mapping REST Clients
- Switch Languages / Keyboard Layouts in Your Delphi Application
- Visualizing physics using FireMonkey
- Delphi 17th Birthday Webinar Coming
- RAD Studio XE2 in Action Live in Italy
- It's Delphi's Birthday and You're Invited
- Embarcadero News - February 2012
- Delphi Developer Days 2012 - Washington DC/Baltimore and Chicago
- Delphi XE2 Boilerplate DataSnap Server and jQueryMobile Client
Marco Cantu
Delphi Mapping REST Clients
I've finally posted on my public Subversion repository devoted to Delphi REST clients two of my geo-coding and mapping demos, and particularly the Google Maps Delphi client.
GeoCodingThe first is rather simple Geocoding applications, returning the latitude and longitude of a given city you enter or of all the cities in the classic customers.cds database. Code at http://code.marcocantu.com/p/delphirestclients/source/tree/HEAD/GeoLocation.
Maps in a Windows ApplicationThe second starts with the same data, but lays it out graphically on a map, as you can see below. It embeds the Geocoding code to create a list of cities and positions, but it also creates a fully working Google Map (not a static image) customized with the positions of the various customers in the database table. Since Google Maps is browser based, the Delphi application embeds a TWebBrowser, but rather than connecting to an external web server, it embeds one. The application is a Web client that uses itself as a server, passing a fixed HTML file and a dynamic XML file with the data taken from the DbGrid and its dynamic ClientDataSet.
Both applications require to sign up on Google, create a developer id, and add it to an INI file named like the program itself in the user's home folder (or "AppData\Roaming").
How to get it? Since I've been showing this application for a long time, I should have posted it before, thanks to a Delphi developer who asked me the code over email the other day. You won't guess how many people keep asking me the source code for this very old blog post of the same program, which has some of the description. Full source code at http://code.marcocantu.com/p/delphirestclients/source/tree/HEAD/GoogleMappingDemo.The command for getting all of the REST clients is:
svn co -r HEAD http://code.marcocantu.com/svn/marcocantu/delphirestclients
Want to Contribute?Finally, this repository is open for contribution: if you have Delphi applications connecting to the web for getting data and that can be considered REST clients, you are more than willing to share the code over my repository, keeping full credit and copyrights (but making the code available for free, of course). Similarly, if you have any suggestion, correction, or improvement, feel free to comment on the code site, here on this blog, or send me an email.
Delphi 17th Birthday Webinar Coming
David I of Embarcadero is inviting everyone to celebrate Dellphi's 17th birtday on... Valentine Day, February the 14th:
Delphi v1.0 was launched at the Software Development Conference on February 14, 1995. Several thousand developers gave the team a standing ovation during the launch.
I was there... and I'm certainly going to join the webinar (likely the first time slot) and celebrate. Will also blog, stay tuned.
RAD Studio XE2 in Action Live in Italy
Three cities in Northern Italy will see three Live Delphi events in 2 weeks including a session of mine on FireMonkey. For the Italian Delphi developers. or at least developers who speak Italian.
The event is organized by Embarcadero, with BitTime and Wintech Italia (my company). Main focus will be FireMonkey and DataSnap (with a session by Daniele Teti). The same event will be held three times in three consecutive days (February 20th to 22nd) in Bologna, Padua, and Novara (halfway between Milan and Turin).
More information and registrations on http://forms.embarcadero.com/forms/EM12Q1ITRADXE2inActionevent.
Visiting Alabama
I've been on a trip to the US last week, and quite busy, so I didn't post to the blog for quite long. Trying to catch up now, but first a short summary of the trip.
Last week I was for 5 days consulting in Birmingham, Alabama, at OneDomain. Very nice and successful company, fully focused on Delphi, and looking forward to migrate to XE2 and a DataSnap architecture. This was my second visit, since I had already been there a few years ago, and I really enjoyed it. Since I had to spend the Sunday in the US, I took the opportunity for a (free) stop over in New York (I thiink I'm getting quite good at buying flights, could set up a travel agency if things go wrong in software). As you can see from the images below, I had time for a short visit to Manhattan downtown, nice under an inch of snow. From left to right, "Construction at WTC", "Under Brooklyn Bridge", "Defenses at Wall Street", "Statue of Liberty from Battery Park".
After that I flew to Atlanta, and from there I drove a nice car (thanks to another good offer) to Birmingham. Spent a full week training and consulting (see images below) in a great weather, and had a little time for shopping Lego for kids. From left to right: "Car in front of Office", "Training", "Training", "Food break", "Shopping for Lego".
Full set of pictures on Google+ at https://plus.google.com/u/0/photos/109099686252303180605/albums/5703813642509841169.
PS. My next US trip will be for Delphi Developer Days 2012. Want to join our Delphi classes? Visit http://www.delphideveloperdays.com/
The Pascal Spring (by Verity Stob)
Verity Stob has released on The Register Very a new amusing new piece on "The Sons of Kahn and the Pascal Spring", which has already been twittet and blogged, but it is worth noticing.
In the first part, there is an interesting assessment of the failure and troubles of competing technologies (" Sharpers of Dotnet were also troubled, especially the cult of Silver Light" and "the Sharpers were laughing compared with the fate of the tribe of Flashinites"), as an explanation of the success of Delphi XE2 and the gang of "discotheque of Embarcadearohdearohdearyme" who "bought in stuff from Europe and Russia".
Interestingly enough, the last part is devoted to the fact the Delphi factions instead of rejoicing are fighting around the use of FreeAndNil... something I tried to avoid blogging about, but might not resist.
Great job, as usual, Verity: "if this is the Second Coming, then it is not quite as I had imagined it."
Delphi Developer Days 2012 Very Early Bird and Guest Speakers
Delphi Developer Days is the yearly conference/training class I organize with Cary Jensen in the USA and Europe. We are planning 2 US + 4 European stops (in 4 different countries) this year.
Very Early Bird
The very early bird signup for Delphi Developer Days 2012 (with 25% discount) expires on January 20th, for each and all of the dates (March through May). If you are interested in participating, book ASAP for the extra discount. Previous attendees will still get a good rate, but not the general public. Did I tell you this is one of the best (and most well attended) Delphi training events of the year? Details at http://www.delphideveloperdays.com/ .
Book Early, Might Get Full
Another reason for booking early (before or after this first deadline) is that some of the locations are filling up quite nicely, and might as well get full. If a location gets fully booked, you'll have to pick a different city and date. First come, first served, of course. Seems Rome is still quite empty, though.
Guest Speakers List
Finally, we do have a complete guest speakers list:
London, United Kingdom:
Stephen Ball, Embarcadero Technologies
Amsterdam, The Netherlands:
Bob Swart,
Bob Swart Training & Consultancy
DC/Baltimore area, USA:
Jim McKeeth,
RemObjects Software
Chicago, USA:
Ray Konopka,
Raize Software
Frankfurt, Germany:
Bruno Fierens
TMS software
Rome, Italy:
Daniele Teti,
BitTime
Of course, I'll take the advantage of this blog post to thank all of these Delphi experts, who've accepted our invitation.
As I mentioned on twitter, I've been doubling as a travel agent, to get my various flights. Most are booked now, See you at Delphi Developer Days!
Delphi and Facebook Base64 Url Encoding
Was working on a Delphi server used to build a Facebook application, when I bumped into an odd Base64 decoding issue. If you look at the Facebook page documenting their Signed Request parameter, you can see it has a first part with an encoded signature (which I won't really mention here) plus some JSON data encoded in Base64. This looked trivial, but as I started using Indy's TIdDecoderMIME class, the result would be correct... but only at times. Other times, the final } of the JSON string was missing. Now, since there were three closing braces at the end of the specific error situation, I didn't spot the error immediately, the JSON string apparently looked good:
{"algorithm":"HMAC-SHA256","issued_at":1111111,"page":{"id":"-omitted-","liked":true,"admin":true},"user":{"country":"it","locale":"en_US","age":{"min":21}}If you look at it carefully, you'll see that the third final brace is missing. So now I could figure out while the JSON parser was crashing badly on me (by they way, I'm using JSON SuperObject for this specific project, nice class). Back to the Facebook documentation. They did say "a base64url encoded JSON object", with a link to Wikipedia, but the link doesn't really explain much:
"modified Base64 for URL variants exist, where the ' + ' and ' / ' characters of standard Base64 are respectively replaced by ' - ' and ' _ '," and " Some variants allow or require omitting the padding ' = ' signs "
Saying there are some variants of an algorithm is not really the best way of documenting it. Facebook doesn't really say which "variant" it is implementing, but, well, at least you can guess among a few options. Moreover, the demo simply calls a PHP function, base_url_decode, and doesn't offer much advice.
Initially I though of a problem with the Indy decoding, tried a couple of alternatives, went to nowhere. In fact Delphi has another SOAP-related Base64 decoded, who was doing the opposite, that is adding some garbage at the end of the string. Now that I knew where the issue was, it was easy to google "base64 decoding facebook" and find a nice blog post, http://qugstart.com/blog/ruby-and-rails/facebook-base64-url-decode-for-signed_request/. This is written in Ruby, but having a minimum of description, I could translate it over to Delphi in very little time (see image below for formatted version):
strFixup := strInput + StringOfChar ('=', Length (strInput) mod 4); // nope, fixed below strFixup := StringReplace (strFixup, '-', '+', [rfReplaceAll]); strFixup := StringReplace (strFixup, '_', '/', [rfReplaceAll]);Update: as suggested in a comment below, this is not correct, as when there is one extra byte we need to add 3. However, in case of zero extra bytes, we shouldn't pad with 4, so evern the original Ruby code seems wrong. I've now fixed it with: (4 - Length (strInput) mod 4) mod 4, as in the image below.
To be honest I have to say there is a Q&A in the Facebook page I didn't initially read. It says "if you are missing a few characters, you are probably using normal base64 decoding instead of base64url decoding. See wikipedia ." But, again, wikipedia said there are several variants, come on Facebook! Even more surprising it that the provide a sample conversion at the very end of the page ("Do you have any example?)" , but that's actually only half of the what's encoded in the initial string!
Thanks to some very approximate Facebook documentation I wasted a few hours. I think documentation for online APIs should be much more precise and do't take for granted everyone is using a single programming language in the world!
From Delphi to Android
Android is bigger and bigger every day. What does this mean for Delphi programmers, how can you move knowledge and code? How can you program in Object Pascal for Android? An overview of the current options in a rapidly moving area.
It is about a month since I first considered writing a post on this topic, but given this is a rapidly evolving area I'm sure this is a better timing. having just seen two / three articles on specific technologies, I think it is time to get this moving. Let me first add a couple of personal considerations:
- I think Android is big and will grow a lot. I've been using an Android phone for over an year, and I like it. Won't trade it for an iPhone or Lumia. I own an iPad, find it much more interesting than I anticipated (this is worth another post), but Kindle Fire, the coming GPad (Google iPad Clone), and more options will open this area to Android as well.
- I think development tools for mobile are still in their initial stage and will grow, landscape will change.
- I'm not generally terribly fond of code converters (sorry for those building similar tools, but I'm negatively biased).
Having said this which are the real and practical options for Delphi developers who want to build Android applications? These are the options I've noticed, let me know if I miss any, and if I missed any key information (feel free also to add more details, here I'm trying to provide summaries).
Alternative Android Development OptionsBefore we look to the available Delphi-oriented tools, let me try to summarize the options for building Android applications:
- Writing Java applications for the Delvik virtual machine, generally using Eclipse and the Android SDK and plug-ins. This is the standard and mainstream appraoch.
- Writing HTML + JavaScript Web applications optimized for the device, maybe using a library like jQuery Mobile. You can simply point users to URLs, or embed the page in a true Android Web App, and even interact with the device using a library like PhoneGAP. What's interesting in this model is that you can use the same application also on iOS.
- Write native applications using the NDK, generally in C or C++.
It is interesting to notice that different tools that bring the Delphi language (or Object Pascal) to Android follow each of the three models above. Here is a summary:
- Oxygene for Java, by RemObjects, is a tool for writing Delphi-like code (or more Delphi Prism-like code) in Visual Studio converting it to Java for Android. Has a nice way to let you refer to any existing Java library, more or less like Prism does with .NET libraries. Read more at http://www.remobjects.com/oxygene/java.aspx and Brian Long's article at http://blong.com/Articles/OxygeneForJavaIntro/OxygeneForAndroid.htm. With this tool you create Java applications.
- SmartMobileStudio (formerly OP4JS) is a tool to convert Delphi code to JavaScript and create web applications. Official site is at http://www.op4js.com/. Primoz has a nice article at http://www.thedelphigeek.com/2012/01/first-steps-with-smart-mobile-studio.html. I tend to disagree on the main rationale (JavaScript is low level / not good / too complex / etc), but still this tool might get you to code faster. With this tool you create Web apps.
- Use FPC (Free Pascal Compiler) to build native apps, as detailed by Uwe at http://www.bitcommander.de/blog/index.php/2011/12/19/fpc-android-boot/. After all, if Embarcadero is using FPC for iOS, it could also be good for Android. Still quite an early version, but interesting. And native.
- Use Delphi DataSnap REST engine with a proper library to build Web Apps, like I did and documented on this blog at http://blog.marcocantu.com/blog/mobile_jquery_delphi_rest.html and http://blog.marcocantu.com/blog/web_andoird_app_delphi_datasnap.html. Yes, you need to write some JavaScrip, but can also use Delphi to generate some, as I do in my Relax Framework. You can probably use the JavaScript REST proxy also from SmartMobileStudio, but I'm not sure about this.
- Use Eclipse ... and Delphi's Mobile Connectors for DataSnap. You can still write the core code and the database access code in Delphi, and code the UI in native Android Java. Or possibly use Oxygene for the front end, and Delphi for the backend. Or other server plus client solutions. Bittime has written a "Connect Four" app with this model, see https://market.android.com/details?id=com.bittime.connectfour&hl=en.
- Wait... for a future Delphi for Android, and learn FireMonkey for now, as it seems likely the future, rumored, unofficially promised Delphi for Android will have the same user interface of the current Delphi / FPC for iOS, ties to OpenGL. At the 24 hours of Delphi, JT and DavidI promised a webinar for presenting the new roadmap in early 2012... so I'm waiting. Will this be a native / NDK solution?
Again, there might be more options and alternatives, particularly in the Web App arena, but this offers you some alternatives... to get to Android or get ready for it. Awaiting your comments (better on the blog than on Facebook, but anything goes).
Why Skype used Delphi?
This page on Quora about Skype is quite old (two years, which in the Internet age is a lot!), but wasn't linked much and wasn't linked by myself although I did blog about Delphi and Skype several times. Came to my attention last month, and now that I'm doing my new year email cleaning up, find it is still worth sharing.
Original link on http://www.quora.com/Skype/What-programming-language-was-Skype-originally-written-in?mid=55546 . I think it is very relevant for Delphi, even if the decision appears somewhat casual.
Amazon S3 Clients for Delphi XE2
I've written new articles on Amazon S3 (Simple Storage Service) from Delphi for the latest issues of Blaise Pascal Magazine (http://www.blaisepascal.eu/). That's specifically issue 19 and 20.
The source code of the two projects has been added to my Delphi REST Clients repository (http://code.marcocantu.com/p/delphirestclients/), specifically at:
- http://code.marcocantu.com/p/delphirestclients/source/tree/HEAD/AmazonS3_XE2 for the VCL application using the native Amazon S3 classes, new in XE2
- http://code.marcocantu.com/p/delphirestclients/source/tree/HEAD/AmazonS3Monkey for the FireMonkey version, which also uses LiveBindings, despite some issue.
I'm still trying to figure out why the Amazon S3 components seem to crash on the Mac, as this would be a nice project to move over.
Going to publish quite a bit of FireMonkey code this month, will create a specific code project... this is just a start.
My Year in Cities, 2011
Very busy and not blogging much, but I'll catch up. As it is now a tradition on this blog, this is my 2011 in terms of cities I've been to, with a few new entries. I did this in 2006, 2007, 2008, 2009, and 2010. If you haven't seen it in the past, this is a list of cities I've been to in 2011, for either work or vacation. The rule is: Places I've visited in 2011 for at least one night, in chronological order.
- Piacenza, Italy (where I live)
- Arezzo, Italy
- Padua (or Padova), Italy
- Paris, France -- for Embarcadero meeting
- Washington dc, USA
- Baltimore, USA -- for Delphi Developer Days
- Houston, USA -- for Delphi Developer Days
- Atlanta, USA
- Frankfurt, Germany -- for Delphi Developer Days
- Amsterdam, Netherlands -- for Delphi Developer Days
- Gunzburg, Germany -- for Legoland
- Gropparello, Piacenza, Italy
- Courmayeur Mont Blanc, Italy
- Paris, France -- for CodeWay Tour
- Koln (or Cologne), Germany -- for Delphi tage
- Ankara, Turkey -- for Delphi XE2 event
- Verona, Italy -- for ITDevCon
- Bolzano (or Bozen), South-Tirol, Italy
Well, it was another busy year, and with a great new version of Delphi. I've already many trips planned for early 2012, including the new 6-cities tour of http://www.delphideveloperdays.com/ between March and May.
I wish you all a great 2012, hoping it will bring us Delphi for Android before ... the end of the world. Cheers.
24 Hours of Delphi Today
In an hour or so David I will kick off a new 24-hours of Delphi event, featuring also myself (around 7pm, European time). To sign up visit http://embt.co/Delphi24. The detailed program (a bit hidden, I have to say) it at:
http://blogs.embarcadero.com/davidi/2011/12/16/41441/
As you can read there, the even will start today at 12:00am PST / 08:00 GMT / 9:00 Central European Time . Speakers include Pawel Glowacki, Stephen Ball, Jim McKeeth, Bob Swart, myself, Delphi program manager JT, Anders Ohlsson, Alister Christie, Bruno Fierens, Cary Jensen, Andreano Lanusse, Tomohiro Takahashi (speaking in Japanese!). The live interviews will be intermized by CodeRage 6 replays (well, they need to get some sleep after all).
This is my specific section (but there will be also some replays of my CodeRage 6 session), focused on the client phone app I recently blogged about:
10:00am PST (Dec20) / 18:00 GMT (Dec20) / 19:00 CET (Dec20) – Marco Cantu (
http://www.marcocantu.com/
)
Building a web phone client with a Delphi REST server based on jQueryMobile,
Delphi Developer Days 2012
, Delphi Books, and Q&A
Stay tuned for the next 24 hours, if you can!
Delphi Developer Days 2012 Official Announcement
Cary Jensen and myself are officially kicking off the new edition of DDD, with 6 stops in Europe and US in March-May 2012. You can read the more official press release at http://edn.embarcadero.com/article/41923.
This is a two-day event (in between a conference and a regular class) that has both joint session in which we compare views and offer insights, and parallel sessions in which you can pick a topic and listen to either myself or Cary. For the spring 2012 we are going to hit 6 cities, 2 in the US and 4 in Europe:
- London, United Kingdom: March 26-27, 2012
- Amsterdam, The Netherlands: March 29-30, 2012
- Washington DC/Baltimore, USA: April 16-17, 2012
- Chicago, USA: April 19-20, 2012
- Frankfurt, Germany: May 14-15, 2012
- Rome, Italy: May 17-18, 2012
Unlike past years, we are alternating 2 European sessions with the one in the US. This means that developers in Europe can pick two different time frames, depending on their expected workload in the period. Also, while we are getting back to some cities we've been in the past, including London and Chicago that we missed last year, there is a new entry, Rome. The hope is not only to attract Italian developers, but also international developers looking for an interesting destination (and a bit unusual one for IT events). That's why in Rome we picked a downtown location, unlike most other cities.
In terms of content, the goal is to cover all new Delphi XE2 features but also recap recent Delphi extensions and a few classic topics. The joint sessions will be:
- Delphi XE2 Features You Might Have Missed
- Delphi Database Strategies
- Introduction to FireMonkey
- Delphi Internet Applications and Delphi Mobile Applications
- Delphi Tips, Tricks and Techniques
Sessions given by us individually will cover ClientDataSet, DatSnap, more FireMonkey, RTTI, dbExpress, LiveBindings, Unicode, and jQuery. The complete program (still subject to change in the sessions sequence and timing) is available at http://www.delphideveloperdays.com/descriptions.html.
We'll give to all attendees a very large courseware with white papers (not slides) and lots of free software licenses donated by our sponsors, which include Embarcadero Technologies, Sybase, /n software, Devart, Gnostice Information Technologies, RemObjects Software, Sisulizer, TechXtend / Programmer's Paradise, and TMS software. I'll blog again about some of the details of the event, but for now notice that there is a 25% discount in you signup before mid-January. So act soon, and save a lot!
Delphi XE2 Update 3
Embarcadero has released Update 3 for Delphi XE2, continuing with an almost monthly update cycle. The new update is a whopping 412 MB and you can get it in the Registered Users page (specifically at http://cc.embarcadero.com/item/28670) and with the Check for Updates featuer of the IDE. There is also a new ISO with the updated product installation image. As in the recent updates, the PAServer and FireMonkey portions of the installation that you need to install on a Mac must be set up manually.
What's in this new update? A new standard iOS style more complaint with platform standards (a significant feature for iOS developers), a new VCL style, and a ton of bug fixes. There is also an extension for the dialog modal results enumeration (for both VCL and FireMonkey). A very detailed description is at http://docwiki.embarcadero.com/RADStudio/XE2/en/Release_Notes_for_XE2_Update_3 while the list of fixes is at http://edn.embarcadero.com/article/41831/. Among the fixes I noticed:
- Fixes in Version Info in the Project Options
- Fixes in VCL Styles
- Fixes in 64- bit debugger and in the memory manager (for 64-bit apps using more than 4GB)
- Compiler fixes for generics, 64-bit, and more
Of course there are also many expected FireMonkey fixes, including some that were really needed and some relevant ones for iOS. Some of those I was waiting for are:
- TEdit: SelectAll should not be called when clicking on an edit
- TCheckbox should check on Mouse Up
- FMI: bad quality of loading image on iPad
- Having a ShowMessage with short text containing spaces, the text is wrapped but height is not adjusted.
In other words, this is another must-have update.
Web Android Application for Delphi DataSnap
I've built a simple Web Android Application based on the jQuery Mobile client connected to a Delphi DataSnap server I already blogged about.
The application has only a full screen Web browser control, and behaves exactly like the mobile web page. However, you can activate it with the icon (I know, I've been lazy and left iin the default Android application icon!) and shows full screen, that is, without the browser address bar and other browser elements. I've not even published it on the Google Android Market, don't think it is worth for such a simple demo application, but if you have enabled the installation of custom applications on your Android phone, you can get install it simply following the link below:
http://ajax.marcocantu.com/android/dsnap_jqmobile.apk
As an alternative, download the file and email it to you phone, the phone GMail client let's you install an APK attachment directly. I know it has quirks (user interface updates are not as smooth as in the browser based version), but my goal was simply to demonstrate this is feasible and not too complex.
Now I'lls tart looking for an idea to build a real Android application with this technology (Delphi DataSnap Server, HTML, jQuery Mobile, Android Web Application wrapper)... waiting for FireMonkey to show up on the platform.
Update: Images below
Skype, Delphi, and Nice UK Job
As you know Skype for Windows is written in Delphi (and if you want a further prove, keep reading). Since Skype is likely the most well-known Delphi application and the most used worldwide (with hundreds of millions of downloads), it is obvious that Delphi developers are fond of it, even despite the recent acquisition by Microsoft. Some people though the deal could have forced the Skype client to be rewritten in another programming language.
However the Job description posted yesterday for a developer based in UK, for working on the Skype for Windows client, dispel the worries and might also be a good opportunity for some of you. Here are some key elements (reported in case this is later removed):
- "The Skype for Windows product is Skype's flagship product, with millions of users around the world. We are expanding our team and looking for talented developers who have a passion for developing user interfaces and being on the leading edge of technology"
- Requires "strong knowledge and substantial commercial working experience with Delphi 2007 / Delphi 2010"
Of course, you can find more reading the full description at http://www.linkedin.com/jobs?viewJob&jobId=2239543. Image below for future memory.
Mobile jQuery Client for Delphi REST Server
During a session last Friday I built a mobile JavaScript client (based on jQuery Mobile) which runs on both Android and iPhone and connects with a Delphi XE2 DataSnap REST Application.
The REST server just a standard DataSnap REST application exposing a few methods. There is a pretty basics ReverseString (used to test the core behavior), plus a function returning a list of employees (from the classic InterBase/FireBird Employee database), which populates a list arranged by department. Finally, you can ask for details of the given employee.
The server has three methods:
function ReverseString(Value: string): string; function ListEmp: TJSONArray; function GetEmpl (empno: Integer): TJSONObject;While the first and the last are very simple, the second is a bit more complicated as it queries the DB by joining employees and departments and creates a two-levels list with the departments and the employees in each of them. This is the SQL query:
select e.EMP_NO, e.FIRST_NAME, e.LAST_NAME, dept.DEPT_NO, dept.DEPARTMENT from Employee e inner join DEPARTMENT dept on dept.DEPT_NO = e.DEPT_NO order by dept.DEPT_NO, e.LAST_NAMEThe code scans the resulting dataset and produces a nested JSON array like the following:
[{"dept_no":0,"department":"Corporate Headquarters","employees": [{"emp_no":105,"last_name":"Bender","first_name":"Oliver H."}, {"emp_no":12,"last_name":"Lee","first_name":"Terri"}]}, {"dept_no":100,"department":"Sales and Marketing","employees": [{"emp_no":85,"last_name":"MacDonald","first_name":"Mary S."} ...Now the interesting part is in the client application, which is a single HTML file based on jQuery Mobile (http://jquerymobile.com/) and made of three separate pages, alternatively shown. The page links with special CSS styles to create buttons and to turn HTML lists into controls like those on your phone and to make them touch-friendly.
For example the top part of the main page (see first image below) is defined with some rather plain HTML:
Reverse
Following pages use the same approach for showing the list of employees (which can be filtered on the client) and the individual employee data. Again, the HTML is pretty simple and the JavaScript processing the page is not much different from what you'll use in a standard HTML application. Here are the other pages:
Now I decided that the best way to test it was to make it "live", so that you can point your own phone browser to:
http://ajax.marcocantu.com/mobiledsnap/
and see for yourself how it works. (You can also use a standard desktop browser, but the user interface will stretch horizontally and look quite weird). Both Android and iPhone should work fine, which is a big advantage of using an HTML/JavaScript-based solution for building pages for phones. This could be extended into a full phone application on two counts. First, you can host it in an application, so that the browser becomes "invisible" to the end user. Second, you can integrate jQuery mobile with PhoneGap to access the native features of the phone. Might explore these extensions in the future.
By the way, notice you need the trailing / or the page won't work. In fact, the Apache Linux web site hosting ajax.marcocantu.com (which is very out of date) use a proxy configuration to redirect anything in that virtual folder to a Delphi XE2 application running on a Windows virtual machine hosted by the same Linux server.
PS. I know, I should have blogged about Oxygene for Android, rather than jQuery Mobile, but both solutions have their role, and this is something I worked on over the past weekend.
Windows 8: Redo or Business as Usual?
Interesting debate on Dr. Dobb's: Redo your development or keep going with your current code?
Over a month ago, Andrew Binstock wrote an article about "Windows 8: Microsoft's Development Re-Do" at http://drdobbs.com/windows/231700224. He claims the new Metro UI and WinRT require developer to rethink their applications and possible change their tools.
This week, Dino Esposito (one of the top Italian technical authors ) in an article titled "What Exactly is Windows 8?" at http://drdobbs.com/windows/231902075 states that most developers should keep their application on classic Windows, that Windows 8 is two operating systems in one but most business applications will stay on the traditional UI. Business as usual.
I've also read lots of reports about the Ballmer squarely positioning Windows at the center of Microsoft's future (and Paul Thurrott claims this might be a bad idea at http://www.winsupersite.com/article/windows8/microsoft-windows-141383) and some interesting discussion about "what if Windows 8 fails" (Windows 8 Failure Could Set Off Tech Industry Chain Reaction).
There are still too many things that are not clear to me, so take this list as "impressions" not "ideas":
- Windows is here to stay in business environments, no matter what, but its role as a consumer OS might decline significantly. No wait, is declining today, because of tablets.
- Having two different flavors of Windows 8 (and different devices optimized for each) will cause much confusion, at least initially.
- I don't think the Metro UI makes a lot of sense on a business PC, unless you consider using the browser for most of your work. But at that point you can run Chrome on the traditional Windows UI.
- It is good to know Delphi R&D has plans to support WinRT, along with keeping its WinAPI support at its current great level (comapred to Microsoft weak solutions for the Win32 API).
- If Metro will run on tablet which won't have Win32 (they'll have only the WinRT and use ARM), I'd rather buy an Android tablet or a Kindle Fire. Why use Windows if it doesn't run Windows applications? That's the great advantage of the Microsoft OS, but "a Windows not running Windows apps" becomes a limited advantage. Did I already say it will confuse people?
- I think my phone should look like a phone, my tablet a table... but my PC should look and behave like a PC. No fingers on screen, please. And no single window on screen (for example I like keeping a Skype chat on the side while doing some work in a main window). And better multi-monitor support (not sure Metro has it).
- At times I fell Microsoft tried to change the UI with the Sidebar (you know, small tiles powered by HTML and JavaScript) and it failed. Part of Vista overall trouble. Now they have bigger and more "active" tiles you program with HTML and JavaScript. Oh, wait...
Again, I haven't really used Windows 8 and have not a real opinion, only a few doubts, and I'm really interested in what you think. Would you side with Andrew or with Dino? Are you going to rewrite your applications for Windows 8?
FireMonkey Webinar Replay
The replay of the video of my FireMonkey webinar is now available from Embarcadero. You'll have to fill a form with your contact information to receive the actual download information. Here are the relevant pages:
- Main RAD Strudio in Action FireMonkey page: http://www.embarcadero.com/rad-in-action/firemonkey (including the white paper download)
- EDN article covering the webinar: http://edn.embarcadero.com/article/41830
- On-demand webinar replay download form: http://forms.embarcadero.com/forms/AMUSCA1111CantuFireMonkeyWebinar11-15
I still have to post the examples to my SVN repository and add some more, start creating extra videos, write much more, and help Delphi developers understand FireMonkey, Anything specifically you are looking for? Feel free to ask and help me prioritize.
FireMonkey Webinar QA
Embarcadero has published the transcript of the question and answer sessions at the end of the webinars I did last week. The full set is available at Q&A log files from the Marco Cantu RAD in Action Webinar “Building Rich Business Applications with FireMonkey”, on http://edn.embarcadero.com.
Here are only the most significant entries, with some further comments
Q: How to use data grid with LiveBindings?
A: You can use LiveBindings with FireMonkey's StringGrid. --- Now LiveBinding is not the simplest feature to use, but they are very powerful. Also, FireMonkey comes with more LiveBinding options thatn the VCL.
Q: Will there be any tools to move current Delphi apps to FireMonkey?
A: MonkeyGroomer ( http://pascalcoder.blogspot.com/search/label/MonkeyGroomer ) and MIDA( http://midafiremonkey.wordpress.com/ ). --- Actuallty the latter has a new home site at http://www.midaconverter.com (I'll blog about it ASAP).
Q: What iOS features are not available? (e.g. accelerometer)
A: Everything on iOS is available via code in your FireMonkey applications. Use the iphoneall unit to get at everything. Anders Ohlsson has lots of example code at http://blogs.embarcadero.com/ao/category/ios . Anders is also wrapping the code as components see his iOS component blog post at http://blogs.embarcadero.com/ao/2011/10/28/39192 . -- not much more to add, if not that I'm going to focus on this in the coming weeks.
Q: I don't use XE2 yet, what's the requirement in order to build XOS apps in Delphi running on Windows? Grazie
A: For OSX - everything is built in the XE2 IDE. You don't even have to have a Mac. Best practice would be to do final debug on a Mac, Mac Mini for final testing. -- Specially, I have a Mac Mini that I use as target, as I recently blogged. Others use the host in their Mac a Windows virtual machine with Delphi XE2 installed.
Q: Marco, Thank you for helping me understand FireMonkey. Please keep up your great work. Are you going to post more videos on YouTube?
A: That is the idea - Marco will do more videos, time permitting --- that's not a promise, but I'll try to create YouTube video while working on my new FireMonkey book.
Again, there is much more in the Q6A, including many questions about Android support for which Embarcadero offered a reply, not me... so I didn't #34e them here even if they are probably the most interesting questions! Same for other questions about "missing" features that are int he current product roadmap.


