If you are an experienced Delphi developer and you thought of writing an application or utility which would work in a centralized model, for which a web application would be great, but shied away from writing them due to lack of familiarity with Web development tools, Morfik is just the right tool for you. This lack of familiarity is for many the result of rejection of these tools, in general, due to their concepts and usage principles which do not help developers to be productive. Let’s be honest. After working with Delphi for years, text editors with HTML syntax highlighting and some help with the HTML tags are quite disappointing.
Programming a Morfik application is, in many ways, very similar to programming a Delphi application. The Morfik Framework uses many concepts which will be immediately familiar to any Delphi developer, from high-level objects such as Forms to the smaller helper classes such as string lists.
Morfik allows Delphi developers to become immediately productive in creating sophisticated Web applications, Web Services and even browser-only applications. In fact, Morfik is the easiest, most powerful path a Delphi developer can choose to create Ajax Web applications while retaining all his/her familiarity with language constructs, Framework and environment.
To a Delphi developer, at first Morfik looks very similar to Delphi. It really is, but in order to be a Web development tool, Morfik must support the characteristics that make the web special but which, at the same time, makes it different from Win32. Most differences in how to do something in Morfik from how you would do it in Delphi comes from the different underlying platforms: Web vs. Win32.
Source Code Similarity
In order to better illustrate the familiarity a Delphi developer will feel when working with Morfik the source code of a simple form is included bellow. This is the basis of the Morfik version of the famous Hello World project.
Unit Form1; Interface Type Form1 = Class(Form) Button1 : Button; TextLabel1 : TextLabel; Procedure Button1Click(Event: TDOMEvent); Message; Private { Private declarations } Public { Public declarations } End; Implementation Procedure Form1.Button1Click(Event: TDOMEvent); Begin TextLabel1.Caption := 'Hello World'; End; End.
This application presents a single button in an HTML page and when the button is clicked it changes the caption of a TextLabel control, the equivalent of Delphi’s TLabel, to “Hello Delphi World”. That is all that it takes to create a Web based application which uses Ajax techniques to change its interface at run time.
Though a careful examination of this source code will immediately reveal some differences to the source code of a Delphi Form, it should be obvious that there are many more similarities.
Asynchronous Environment
The asynchronous nature of a Web application is the main initial challenge a Delphi developer faces when starting to work with Morfik.
It is essential that the developer recognizes that calls to the server from the browser side code are asynchronous and that it precludes the creation of browser side code which is exactly the same as one would have in a traditional Win32 application.
The Morfik Framework, which is available in Object Pascal, offers some features which help to minimize the effort for getting into this new world. In order to avoid the need to continually handle the mundane everyday aspects of asynchronously calling the server and receiving the reply (which might come in in chunks) the Morfik Framework implements a set of methods which do this for the developer, when opening forms, running reports or making calls to web services.
Whenever you are writing browser side code, this is one important aspect o keep in mind as it is common for people to forget it and write code as if it would execute synchronously.
Dual Modules
Dual modules are another feature of Morfik which will be new to the Delphi developer and which is, also, associated with the difference in nature of Web applications to traditional Win32 applications. Web applications, most of the time, have both a browser and a server side component to them.
In Object Pascal terms a module is a unit and a dual module actually contains two units with the same name, one for the browser and another for the server side of the application. Within the Morfik IDE the developer can switch from one to the other by clicking on tabs which are available right below the code editor.
Morfik does allow the developer to create both browser-only and server-only applications easily but many developers will probably enjoy the ease and flexibility of the single WebOS project that contains both side of a Web application.
Web Services
Morfik WebOS makes it easy to create Web Service APIs for usage in other Morfik applications or for calling from other platforms. Being an environment specifically designed for the creation of Web applications Morfik creates Web Service enabled applications by default.
Web Service APIs are created in Morfik by creating descendants of the WebMethod class. The Morfik compiler automatically generates the .wsdl file required for other applications to call your services.
Data-bound Forms
In Morfik, unlike, in Delphi, Forms are tightly integrated with data sources. This means that the Forms themselves offer special services which can be used to create data driven interfaces, without requiring any special controls.
Forms in Morfik have bands and behave in a manner which can be considered to be a cross between a plain Delphi Form and a report.
Continuous Forms are specially good for displaying lists of items in Morfik applications. These Forms repeat their details bands for each record/row in a table or in the result set of a query.
Tables and Queries
Tables and queries are first class citizens in the Morfik IDE. Instead of being represented by control icons on Forms or Data Modules, queries and tables are created separately and can be accessed from anywhere in your application.
DLLs and Function Libraries
Though you can call DLL functions from the server side of a Morfik application, if you wish to make a group of functions available to several of your applications you would do so by creating an application that publishes a Web Services interface.
Morfik Plug-in applications are in fact DLLs which are dynamically loaded by a Morfik Host Application Server. The plug-ins can, optionally, also be used with IIS or Apache directly.
Importing Delphi Code
Most Delphi code, which is non-visual in nature, can be reused in a Morfik application, particularly in server side code. If you are a FreePascal developer, you will be interested in knowing that most pure-Object-Pascal code can be directly ported to browser side code in Morfik as well.
Using Delphi as the back-end compiler
Morfik compiles a web application into JavaScript for the browser side and into a binary executable (or plug-in module) on the server side. A Delphi developer who wants to create a Web application with Morfik can choose to use his own licensed Delphi as the backend compiler for Morfik. In this case, instead of using Morfik's default backend compiler (FreePascal) we can use the Delphi compiler. Morfik is compatible with Delphi 5.0 up to Delphi 2007 for Win32. No changes to an application’s source code is necessary in order to switch back and forth between backend compilers so the user can freely choose which ever one suits his/her needs at the time. This makes it easy to use - for example, Delphi 2007 to compile an application for Windows and FreePascal to compile the same application for Linux.

