March 9, 2007 at 7:14 pm
· Filed under Tech, Javeline
SmartBindings
Javeline Platform uses has a strict seperation between model, view and controller. The so-called MVC pattern. The Model is represented by a j:model tag. The Controller the Javeline component (i.e. j:List). The View is the SmartBinding configured by a j:smartbinding tag and others.
The advantages of having a clear seperation are numerous and are out of scope for this article. Suffice to say that by seperating these layers your application will be easier to manage and the possibilities of reuse are far greater.
bindings
In this example I want to create a List which is filled using arbitrary xml from a file (users.xml). The xml looks like this:
The model called mdlUsers loads the file users.xml. The list connects to this model and loads the data. The smartbinding sbUsers determines the view on the data. The bindings section is one of three of the smartbinding. This binding tag contains three rules. The Traverse rules determines the nodes which are rendered in the list using the Xpath statement. The Caption rule determines the caption of each node. The icon is the same for each node and is therefore given a default attribute. This smartbinding will select all user tags and retrieve for each of them the caption from the name attribute, always setting the icon to icoUsers.gif.
I always like to work as efficient as possible and a shorter syntax helps. The example below does exactly the same as the one above.
There are many different transformation rules available. You can specify a mask, use XSLT, JSLT or javascript methods to process the data from XML. Check out he SmartBindings cheatsheet for more information.
Undo & Redo
One of the advantages of using a strict and good seperation between these MVC layers is the ‘free’ undo/redo feature. Each action of the component can be undone by calling ActionTracker.undo(). The undo stack has no limit. In the example above, press the undo/redo buttons after you have removed/renamed some nodes to see the ‘magic’.
actions
Lets say that we have a web service from which we load the users. When we rename a user in the list the data in the model is changed automatically. The data on the server however is not. This is where the actions come in. Each component has specific actions associated with it. Lets take a look at the following example:
The two action rules specify that any user can be renamed and all users removed except the ones with the admin attribute set. When a user is allowed to rename or remove a node the action is executed. In the case of rename an RPC method is called with xpath based arguments. When a node is removed the javascript expression is evaluated which could handle the synchronization of the data.
I have already sent two emails to the Javeline team via the “info@javeline.nl” email
address, but unfortunately I got no response
So I am contacting You directly here via this blog entry; because I have fallen in love with Your layout engine almost immediately ! I am currently doing some research with regard to layout in the native contemporary browsers, and Your approach seems to be really unique ! I have played around with it a little bit and am so impressed right now that I want to leverage Your layout engine ! I know that I can use the packager to extract only parts out of all the Javeline SDK stuff; but I couldn’t make it extract the layout parts … in fact I couldn’t get it to work at all …
I am also very much excited about Javeline in its whole glory, but this particular blog comment shall address the issue of leveraging Your layout engine separately. Is there a technical way to do it ? And what about licensing then ? Or do You know of other layout engines for browsers which are as capable as Yours seems to be ?
I just found your e-mail. It got lost in the spam box somehow. You will get a reply from me on that. It is possible to extract the layout engine using the packager. For what purpose would you like to use it? Please register to the internals mailinglist at http://developer.javeline.net/mailinglists.php and sent your answers there so the community can follow them as well.
Ajax applications connect to a backend. Most popular nowadays is to use REST to connect to a backend. This backend can be written in PHP, Perl, ASP, JSP or any other language. It’s the responsibility of that language to connect to a database using jdbc.
In Javeline PlatForm you would do something like this:
[…] early version of Javeline PlatForm and up untill that moment I had only positioned elements using anchoring. I did remember a nice feature that Visual Basic had, where I could align an element to one of the […]
Guys, I have gone thru the documentation available on javeline.com website nevertheless I am still unable to start with it. There are several examples which I have browse as well but would you have something like tutorial or learn by example so, I can quickly adopt and use your framework?
I’m trying to send a form in JPF. I use a set of form elements checkbox, textbox, etc. I would like to send all these elements with Teleport to a php-script to put the values in a database. I get it to work if I declare the variables within the tags. This seems not very efficient to me.
Is it possible (like plain HTML), to submit all the form elements in one, without declaring them again within the Teleport-tags?