Viewing By Category : J2Flex /
Main
Wednesday, October 10, 2007
j2flex - CRUD operations
In this article I'll talk about the j2flex client side API, more specifically how to read and modify data.
One of the main goals for j2flex was to keep things simple. For a default installation this means, that you do not have to code a single line of server side code to persist you date (of course you can do this if you want by using the server side Java API, but basic CRUD functionality is already inplemented for you). So let's see how this works.
[More]
j2flex website launched!
Just in time before MAX Europe starts next Monday we officially launched the j2flex website. More to come!
Btw, it's j2flex and not J2Flex anymore - the latter was too difficult to write :)
Dirk.
Thursday, September 27, 2007
J2Flex - The main concepts
While the last post introduced J2Flex and the big picture behind it, this article will take a look at core features of the framework. We start with some theory first as this is needed to understand the sample code later on.
The main concept in J2Flex is something called a "meta database", an object-oriented data model stored in a relational database system like MS SQL Server or Oracle. So, how does this compare to a "traditional" approach? For example, imagine you want to build a CRM application with Organizations and Contacts. From a data model point of view a Contact typically stores information like a name, an email address and a birth date. In a traditional database you would probably create a table "contact" with columns like NAME of type VARCHAR and BIRTHDATE of type DATE and so on. The identity (primary key) of the Contact could be an INTEGER and so on. In an object-oriented data model you would not persist everything in one single table but store the different data values in different tables and every table is made to store data of a certain type only. In the above case the NAME and EMAIL columns would be stored in the OBJ_TEXT table (a table which only stores VARCHAR data) and the BIRTHDATE data would get stored in the OBJ_DATE table and so on. So every row in every table only stores single aspects of a whole object. Of course, to re-assemble an object, we need a unique key again. In the world of J2Flex every object stores an OBJ_ID and an OBJ_TYPE value. Both of the are numeric and together they a unique primary key to lookup date from the several tables.
This approach allows us to persist pretty complex data definitions very easily and without much hassle, including 1-1, 1-n and n-m relationships. Due to this dynamic persistance schema, new object types (i.e. business entities) can be added to the system pretty easily without modifying the physical database model. Also, it's super-easy to modify existing object definitions. On the other hand, if you already have a full-blown physical database model in place, it's quite easy to make it work with J2Flex. All you have to do is to add OBJ_ID and OBJ_TYPE columns to your physical data model.
Now that you know how data gets persisted in J2Flex the next question is what to use to query this "meta database"? Well, SQL of course! Probably the best thing in J2Flex' core engine is the SQL Parser. This allows you to use pseudo-SQL statements to query the database. Why pseudo? Because it is no "real" SQL. The SQL you send to J2Flex is parsed on the server side into real SQL before the data is fetched from the database. Why's that? As said above, when a Contact gets persisted, the real data gets stored in several physical tables. The SQL Parser allows you to query the database as if the Contacts would be stored in a table called CONTACT- This is because when you create a new data type "Contact" a virtual table of that name gets created, think of it as the class name in terms of OOP. So querying all Contacts becomes as simple as
select * from CONTACT
Doesn't sound too complicated, does it? The neat thing is that with J2Flex you can send those queries directly from a Flex client to the server. As they are no real SQL queries there's no danger of SQL injections as everything gets handled by the SQL Parser. Also, the SQL Parser only allows SELECT statements, so you cannot call INSERT/UPDATE/DELETE on it. To create, update or delete objects (data) you use a special API which we will see in the next article.
Dirk.
Wednesday, September 19, 2007
J2Flex - A Persistence Store for Flex applications
This is the first article in a series of posts that will introduce J2Flex - a persistence framework for Flex powered applications. J2Flex is the outcome of our day-to-day work with Flex, LiveCycle Data Services and J2EE in real-life projects with the goal to make your life easier.
So what's it all about: When we started with Flex 1.0 back in 2004 we realized quickly that although Flex facilitates integrating with Service Oriented Architectures (SOA) of course not every customer is able or willing to create such an infrastructure just for the sake of using Flex. With Flex 2.0 this is even more true - a lot of smaller shops start evaluating Flex 2.0 but then realize that they do not know how to integrate Flex with their data store. Some of them even do not have a dedicated data store in place and say: "Ohh, Flex is soo cool - but how do I connect to a database?"
This is one of the areas where J2Flex offers a simple yet powerful solution: J2Flex allows Flex beginners to quickly setup a powerful persistence store for Flex applications. With J2Flex you can directly read data from and save data your database without too much worrying about how this works - and without writing server side code. It just works. Sounds nice? Well, it really is :)
But J2Flex also offers a solution for integrating a Flex application into an existing J2EE infrastructure - including mapping the physical data model to the Flex world, dedicated authentication and authorization, workflow support and much more.
If that's still not enough, you can easily extend J2Flex to meet your needs, either through the Flex/ActionScript 3 or Java API. It conforms to Flex 2 Framework standards, can be used with Cairngorm and gives nice integration with the Data Management Services of LiveCycle Data Services.
This was just a little teaser - I'll be posting more information, samples and resources during the next weeks so stay tuned. Btw, the first public demonstration of J2Flex will take place at MAX Barcelona at our booth in the exhibition hall.
Dirk.