The Freja Framework
Background
Since I started working on the Form Builder, almost a year ago, I’ve adopted a radically different approach to web development. At that time, I had firmly embraced the concept of separating structure from presentation using valid XHTML and CSS. The next logical step was for me to catch up with the experienced web developers who preached the separation of data, business logic and presentation. The Model-View-Controller pattern was (and still is) big, but I was more impressed by the REST philosophy and the Service-Oriented Architecture style.
I gave a shot at building an application - the form builder - that would follow these principles. Coded in Javascript, it runs on the client and deals with web services using asynchronous HTTP GETs and POSTs. I found that writing REST services was dead simple. It’s like writing a regular server-side script but it doesn’t need to spit out a HTML page. You just output some HTTP headers and either plain text or a XML string.
Now, since the web services didn’t provide HTML, the client - the web browser - had to create it on its own. XSLT was the perfect candidate. It was a web standard and it was supported by 90% of the browser market (IE5+, Netscape 7+ / Mozilla).
By the time I had the Form Builder working, the Ajax term was coined and I was able to put a name on what I was doing.
Fast forward 10 months: more browsers now support XSLT and XMLHTTPRequest (Opera 9, and Safari - somewhat - ). The Form Builder is now at version 2.0 and so is the Time-Tracker - a small app that started as a proof-of-concept.
But it’s time to introduce Freja.
Framework
Freja is the fruit of this learning process. It is a lightweight and simple Javascript framework that facilitates the development of single-screen, zero-latency web applications.
It isn’t yet-another-Ajax-framework. It does things that no other Ajax tool does and it doesn’t do what most others do. It’s a companion for libraries like prototype and maybe for more complex frameworks like Dojo.
Freja stands for ‘Framework for REstful Javascript Applications’. At its core it’s a XML / XSLT engine, but it’s all abstracted into the Model-View-Controller pattern.
- A model is a XML document obtained from a URL (could be a web service or just a flat file).
- A view is a XSL template obtained also from a URL.
- The controller is the javascript code. Freja provides a set of convenient (did I say elegant?) functions for retrieving, rendering, updating and saving the models.
Learn More
Visit Freja’s home site for Documentation, Tutorials and download.
Technorati Tags: Ajax, Freja, REST, Web Development, Javascript
January 6th, 2006 at 6:49 pm
This is indeed interesting (the idea).
I looked shortly over the code and the available documentation, and I would have a few suggestions:
1. It seems that it requires PHP (srvc-xslt.php) IMHO it should be stated that it’s PHP dependent in the above article, or make it really independent.
2. The tutorials are nice, but IMHO complete working examples (out of the box) would be much better and more efficient for good “spread” of the framework (I would say that this should be for WForms too so).
3. The “Download” should be a Zip that contains everything necessary and at least a working example, so that one is just unzipping, running and can see it in action.
4. Should work not for PHP only. Many use JSPs/Servlets.
Thanks in advance,
Ahmed.
January 6th, 2006 at 9:15 pm
Ahmed thanks for your good remarks.
The framework use an optional server-side service to perform remote XSL Transformations for browsers that don’t have that capability (Safari and Opera <9). If you don’t need to support these browsers you can (corrected) forget that component, otherwise it’s pretty straightforward to rewrite it in a different language. I’ll make an ASP/.NET version soon.
Regarding the tutorial, I wasn’t sure what the best ‘working example’ would be. I was thinking of a (yet another) to-do list to show how it can perform better than similar Ajax apps like tada-list and remember-the-milk.
Any better idea?
January 6th, 2006 at 11:16 pm
> I’ll make an ASP/.NET version soon.
(Please!)
IMHO a JSP version would be more useful
> I was thinking of a (yet another) to-do list…
.
> Any better idea?
IMHO a todo list is overhyped
Instead of one big ‘working out of the box example’ a few more smaller would do it too.
If you still want to do one a little ‘bigger’ than IMHO the best idea would be a stripd down(very striped down) version of the Form Builder (e.g. something like version 0.2 - if there was such a version - so not even the old 1.0).
.
. Almost everything is a reinvented/remade wheel.
.
IMHO this Simple Form Builder would have several advantages over all the other possible “working examples”:
- would not danger your FormBuilder 2.0 - since 2.0 it’s much much more advanced. On the contrary, it would make many more people curious to try the full version.
- it would be much easier since you would reuse allot. I suppose it would be the easiest possible since you already made many versions of the Form Builder. I suppose you would delete more than write
- it would be an innovative example, like the entire web based form building. Innovation is seldon these days
- I can’t think of a better buzz word than a SimpleFormBuilder as a simple working example that guaranteed no one else has done before (all the other frameworks try to “mimic” implement the same old ideas/examples)
- If you make a JSP version for the server side and put a nice article on www.theserverside.com presenting your working example(together with links to your existing tutorials), I think it would be the best marketing strategy ever. I can’t think of a better way to make your framework known (and get traffic for your additional services as a “side effect”
The Java community is much more grateful for quality frameworks since a lot of corporations adopt it as a standard.
One thing is sure: when someone does something innovative in javaland(even a small framework) than it receives many project requests - all framework authors confirm this trend.
Thanks in advance,
Ahmed.
January 27th, 2006 at 9:23 pm
No feedback?
.
Thanks in advance,
Ahmed.
January 27th, 2006 at 9:49 pm
Ahmed, sorry I didn’t mean to leave you without a response. (somehow time flies…)
I’ve been thinking about ideas for a working example, and contemplated for a while doing a simple poll builder (similar to your suggestion of a simple form builder..). It’s still on the drawing board though…
As for the java components… I really see Freja as a pure client-side framework. The existing server-side script is merely a backup solution to perform a task (XSL Transformation) that some browsers can’t do on their own (Safari, Opera
. Writing this component in Java should be fairly trivial (and you’re welcome to give it a try), but that wouldn’t be enough to make it a ‘java framework’.
Of course, no web application can really work without a server-side component, but that’s out of the Freja’s scope .
There are plenty of technologies and frameworks that you can use and as long as they can provide REST-like web services, they should be able to coexist with Freja.
February 17th, 2006 at 12:43 am
[…] As Bill called it Client / SOA will use the same. SOA may not yet be concept which readily communicates ideas. My angle of understanding this begins with asking AJAX: what’s a session?. An alternative angle comes from Cédric Savarese over at Form Assembly in Ajax: It’s not all about XMLHTTPRequest (and part 2), a train of thought which leads to what he’s done with the freja framework. […]