domingo, 1 de setembro de 2013

Android with Delphi - CRUD

POST #023 =======================================================================
Delphi XE5 – (AKA Delphi for Android), is officially out today. It’s neither a Delphi compiler for Java nor generates Dalvik¹ VM bytecode. The compiler named “dccaarm” produces native applications with binary code, compiler builds native machine instructions ARM executables, generating automatically the package .apk. Emborcadaro guys are always stating the word native, the “native machine code” is better than and so on. To be honest, I think “native” here is synonymous of “sex”, anyone talking about it all the time generally is not doing it. In my opinion, seems to be a very interesting tool, despite the price of $ 1.5K - too expensive for most programmers.

Talking about price, size, Delphi and Android, take a look at what I'm trying to build: is a REST server with the old Delphi 7 with Android. The Android Client will list data in a simple widget listview. My first app does something useful, perform CRUD operations such as create, insert, or delete records. Eclipse with Android SDK generates this application to an .apk in 60 KB in size.


AHA! By contrast, an empty Hello World application project in Delphi for Android XE5 – the generated code (file with extension .so) a kind of shared objects library in Linux, is much bigger: around 5MB in size. How quickly does that native binary grow when you add more capability? Normally, I’m very optimistic, but recently I’ve becoming very pessimist with EMBT these days, but this is another story. So please stay tuned on upcoming videos. Next video, I'm going to talk about REST authentication using Android client. Thank you very much for listening, I'm warleyalex from Sete Lagoas, and you take care.

_______
Dalvik¹ Virtual Machine requires that the Java bytecode .class is converted to the Dalvik bytecode, so from compiled Java class files, the files are converted to the Dalvik VM bytecode to native files. dex. The Dalvik virtual machine Android normally does not run Java bytecode.  

quarta-feira, 7 de agosto de 2013

Delphi with jQuery UI Multiselect component

POST #022 =======================================================================
I would like to submit an array of strings from a web form to Delphi mORMot server through GET request.
Suppose you have a multi select jQuery UI control which allows users to select items, you would like to save the multi selected items to a database. When the page is next loaded you want to retrieve the list of items from a remote data source but also set the currently selected items.

I suspect that there is a clever way to do this in mORMot, but here I'm using another alternative approach to pass json encoded array into URL via GET method. My mORMot service I've written seems fine with having an array of strings as input using Delphi type "set with enumerations". The array will automatically be parsed by mORMot.
If you don’t know, ENUMERATIONS is simply a fixed range of named values. Each of the values in an enumeration must be unique in a program. It allows a variable to have one, and only one value from a fixed number of values. Otherwise, a SET is a collection of values of the same ordinal type. Sets allow you to have any combination of the given values - none, 1, some, or all. Sets with Enumerations is used to mix both enumerated types and set types. I know this might look complicated, but it really isn't!



Tags: jquery UI with delphi mORMot; Delphi mORMot UI Settings; Delphi jquery multi select list; Delphi REST server;

Warleyalex from Sete Lagoas-MG, Brazil

terça-feira, 30 de julho de 2013

Delphi with jQueryMobile - Store User settings JSON object in DB

POST #021 =======================================================================
The end-result of this mini-video was demonstrate the aproach JSON based-data or key-per-column. The idea is store UI settings JSON object into Sqlite database. Once stored, I’ll retrieve these preferences when user returns to the web app and set the UI as it was when they last left it at later time. One obvious drawback of this approach is that it makes it VERY slow to find things, but it's fine for small structure of data you don't need to search by.

I'm using meta columns which stores data about the user in JSON format. For example, "roles" object is stored as TEXT in Sqlite database column, and extracted directly as such from DB. You just need to decode JSON string as a JSON object. For instance, it is just one line of javascript. I'm using the stringify method to convert the JS object into a string, store it in the Sqlite database and then pull it back and use the reverse parse method to give me the javascript object back.

Maybe this is neither the best aproach to store UI user preferences nor design-wise or performance-wise, but I believe that it often makes sense to organize small trunk of data and store it in json object in database. That's all.




Tags: smart phones with delphi; Delphi mORMot UI Settings; Delphi jquery mobile; Delphi REST server;

Warleyalex from Sete Lagoas-MG, Brazil

domingo, 30 de junho de 2013

Smartphone with Delphi - Part I

POST #020 =======================================================================
In this mini video, I gonna use the old Delphi 7 to build a mobile web frontend application for displaying "NorthWind Traders" database data coming from a mORMot server. Northwind Traders is based on sample database that ships with Microsoft Access. I use the ideas in Northwind Traders to implement this mobile version.

The end-result is mORMot data server providing data optimized for web browsers available on smartphones, like Blackberry, iPhone, Android and others.  At this time of this writing, I'm going to point out two things:
a) I know barely nothing about application development for smartphones; and
b) this is my first mobile version using Delphi.

I guess many companies are creating mobile applications for their internal staff, for their customers, or both. These applications need access to data, business rules, and business processes.  For architectural and security reasons these applications are typically built to access remotes services that provide the data and functionality that are required by the users.

I believe that it often makes sense to organize those services into a mobile environment built using REST, and delivering data in JSON format. Believe it or not, this is possible using the old Delphi 7. Here, Delphi 7 provides dynamic JSON to a thin javascript client.



Tags: smart phones with delphi; Delphi mORMot with Blackberry; Delphi jquery mobile; Delphi REST server;

Warleyalex from Seven Lakes, Brazil

terça-feira, 28 de maio de 2013

uniGUI with DataSnap - Part 1

POST #019
=======================================================================

This is the 1st part of the mini-video about uniGUI. Developing a stateful Rich Internet Application (RIA) is one of the challenging fields in software development. uniGUI Web application framework makes developing stateful Web applications easier than ever. uniGUI extends Web Application development experience to a new dimension. In my little experiment, I'm using uniGUI with DataSnap.

uniGUI with DataSnap seems to be a good match. DataSnap architecture is more flexible than before. It moves the connection between the client applications and database server to application server and database server while you can connect many client applications to the same application server.


 

Tags: RIA with Delphi; unigui; DataSnap with uniGUI; unigui web application.

Warleyalex from Sete Lagoas, Brazil

terça-feira, 21 de maio de 2013

uniGUI with SQLite

POST #018
=======================================================================
You can create web applications RIA (Rich Internet Application) without the need for many specific knowledge for web environment, such as HTML, javascript, CSS, PHP, etc. You can use the same code base object pascal to create a desktop app and a win32 VCL application RIA web quickly and very easily.

If you do not know, uniGUI is an alternative for developing RIA web applications using 100% AJAX features of the Delphi RAD environment. In uniGUI, most of the business logic, as well as the complexity of threads, managing multi-user access and all data is located in a central layer, running on the server.

You can freely download uniGUI beta, for testing. But if you intend to use it to publish a web application or even a commercial application freeware, closed source, the developer will have to purchase a full license of ExtJS, which costs about US$330. Any uniGUI server requires a copy of the ExtJS library. Due to its licensing scheme, I think even freeware closed source applications are unable to use it. According to the roadmap uniGUI, from version 1.0, it is likely that uniGUI be marketed - in 2013, and the license price will be the "style" of the Sencha ExtJS, around US$330 per developer, ie, to use uniGUI, developer should spend approximately R$1.200,00 (BR).

I was wondering about using mORMot together uniGUI. In uniGUI, since all server-centered activity is hosted in one multi-thread process. Perhaps, make sense to use a local SQLite database engine. I'd like to use SQLite3 as a client-server where the same database will be accessed simultaneously by many clients/threads, accessing a common database. Interesting, isn't it?
 Typically in uniGUI, if you want to show records from your database table on a DBGrid in your application, you will need:

1. TSQLConnection to provide the necessary connection details to the database.  One TSQLConnection can service several TSQLDatasets.

2. A TSQLDataset component which will specify the TSQLConnection component in the SQLConnection property.

3. A TDatasetProvider component which will specify the TSQLDataset in its Dataset property.

4. A TClientDataset component which will specify the TDatasetProvider in its ProviderName property

5. A TDataSource component which will specify the TClientDataset component in its Dataset property.

A TDBGrid component which will specify the TDataSource in its DataSource property.

By setting the appropriate Active properties to true in TSQLConnection, TSQLDataset and TClientDataset you should find that the data will appear in the grid.
__________
I skipped steps 1-2 to simply display data in a DBGrid, for me, the easiest way to edit/delete/insert any of the cell values in a DBGrid with mORMOt and write back do database is using TClientDataSet. On BeforeApplyUpdates event I could capture delta, and put Delta back to to the database using Batch sequences. TDatasetProvider here is like a pipe connecting TClientDataset with TSQLTableJSON. It seems like quite a bit of effort to simply display and modify records in a DBGrid, but that is the way it works!

Yep, this is like bizarre creatures from another planet.


 

Tags: RIA with Delphi; unigui; mORMOt with uniGUI; unigui web application.

Warleyalex from Sete Lagoas, Brazil