An Object Oriented and extremely extensible web application development framework. http://ercilla.webs.com

Saturday, January 30, 2010

Advantages and Disadvantages of JSF (Java Server Faces)

JSF (Java Server Faces) is a buzz word in the web application development domain. It is part of J2EE/JEE5 specification and it is supported by Sun Microsystems (now Oracle). It is also said that it emulates the component architecture of ASP.NET. This combination should make it a winner. I have worked extensively on this framework and know the internals. Lets evaluate the advantages and disadvantages of JSF. We will look at fundamental features rather than pointing out the nitty gritties.

Advantages of JSF

JSF is like an extension to Struts. It follows MVC design pattern and has all the advantages of MVC. A front control to route the events and separation of business logic from view. But whether it has all the advantages of Struts or not is a different discussion. JSF adds to the MVC design pattern a component based architecture to build the view. Each component is a self contained entity. Components like dropdown are coded in JAVA and they take care of rendering required HTML and Javascript, validating submitted data and updating models (Java beans). This architecture has lead to vendors who can independently develop newer components. It's quite a powerful concept.

Disadvantages of JSF

First problem that is quite prominent is its validation framework. Though it sounds great that a component would know what validation applies to it. But think hard, do we really validate a component or we validate data based ? It's an important question. Lets analyze a use case. Say you are creating profile on a website. You have 3 options, namely, save, publish or cancel. If you save, you just need to validate profile name, rest is not yet complete so we need to skip. While publishing the profile every field require validation. When we cancel, not even profile name is required. So, you can see a validation requirement actually depends on the event that you are generating. JSF will be a nuisance while achieving this scenario. If you set a component as required="true", it will validate for anything and everything. JSF gives a workaround for buttons that don't require validation. An attribute immediate="true". The idea is this button will invoke its action immediately. But as you can see. The scope is very limited. If some action requires a different kind of validation, there is simply no way to achieve it. To top it all, you can't customize the error messages for a component differently on different pages. It will keep throwing "value is required" even if you want components to say "First Name is required" and "Email is required".

Second in the list is life cycle. Though component life cycle is one of the selling features of JSF it has shortcomings. It provides adequate steps for submitting data, like restore view, validate, update model and application invocation. But while rendering it makes it a one step process, which is render response. Before render response there is no process for the view to be rendered and after render response it is all done. Many developers get confused with this fact. But dig deep and you will find that in the flow from Login.jsp to Home.jsp. All steps/phases before render response belongs to Login.jsp and there is just one step for Home.jsp which is render response phase. If you are using JSP based view handler then in this phase, both component tree and render HTML get generated simultaneously. If you are using Facelets then it becomes two step process where in the first step a component tree is created then in the next step HTML is generated. This gives Facelets the ability to add features like templates, composition and decoration of web page snippets. But for component developers, available methods to hook their code in are encodeBegin() for start of a tag and encodeEnd() for end of a tag. There are multiple steps that a component architecture needs to provide:

  • Attribute value evaluation
  • Component addition to the component tree
  • Child component creation
  • Component rendering
All these steps need to be overridable by developer who wants to create custom components. With current architecture, complex component development like Data Grid, Data Tree etc will get very difficult. No wonder most of the existing complex JSF components are very buggy and their functionality are limited. They start failing the moment you start embedding random components inside a component like Data Grid.

Shortcomings of JSF

There are some features of JSF that doesn't fall under disadvantages but they fall well short of what they could have achieved.

First one is the navigation architecture. It is an improvement over Struts navigation but it doesn't achieve what it should. Through JSF navigation you can configure the destination of a web page for various events. If the requirement is to return to the page where the current page was reached from, then you will start thinking about hacks. For example, customer search can be performed from various screens, once you select a customer you need to return to the calling page. There is no way to configure that. There is no concept of a flow which will encapsulate few pages that form a unit. Navigation doesn't reflect the action that results in the event generation. Actions are configured on the web page. The features that I am talking about are not very apparent till you read and use a framework like Spring Webflow and Seam. We will discuss these frameworks in a different article.

Second is the managed bean concept. Though managed bean concept sounds great. It serves most of the purpose but where it falls short is that it fails to enforce SOA. The action methods inside a managed bean is supposed to call methods on a delegate class and return the event. But there is no way to restrict developers from writing large amount of business logic in it. If you really want your application to follow SOA, then all the business logic should go to some service method.

Imagine a framework that doesn't fall short on any of the features mentioned above and then provides you lot more. You must have a look at the framework I have created at


I guarantee that you will not find a better one than this ever.

Friday, January 29, 2010

Advantages and Disadvantages of GWT (Google Web Toolkit)

Google Web Toolkit is supported by a strong brand name Google. Some features that you can easily rely upon are the quality and support. But there are some fundamentals that decide how successful a framework can be. Lets look at fundamental advantages and disadvantages of GWT

Fundamental Advantage

GWT takes the web layer programming to JAVA. So, the obvious advantages of Java start getting into play. It will provide Object Oriented programming. It will also provide great debugging and compile time checks. Since it generates HTML and Javascript, it will also have ability to hide some complexity within its generator.

Fundamental Disadvantage

The disadvantage starts from the same statement. GWT takes the web layer programming to JAVA. If you know JAVA, probably you will never look out for an alternative language to write your business logic. It's self sufficient and great. But when it comes to writing configurations for a JAVA application. We use property files, database, XML etc. We never store configurations in a JAVA class file. Think hard, why is that?

This is because configuration is a static data. It often require hierarchy. It is supposed to be readable. It never requires compilation. It doesn't require knowledge of JAVA programming language. In short, it is a different ball game. Now the question is, how it relates to our discussion?

Now, lets think about a web page. Do you think when we write a web page we write a business logic? Absolutely not. Web page is just a configuration. It is a configuration of hierarchical containers and fields. We need to write business logic for the data that will be captured from and displayed on the web page and not to create the web page itself.

Previous paragraph makes a very very strong statement. This will explain why HTML and XML based web pages are still the most popular ones. XML is the best in business to write configurations. A framework must allow a clear separation of web page from business logic (the goal of MVC framework). By doing this a web designer will be able to apply his skills of visualization and artistry to create brilliant looking web pages just by configuring XMLs and without being bothered about the intricacies of a programming language. Developers will be able to use their best in business JAVA for writing business logic.

Finally, lets talk about the repercussions in direct terms. GWT breaks this principal so it is bound to fail. The cost for developing GWT application will be very high because you will need multiskill programmers to write web pages. The required look and feel will be very hard to achieve. The turn around time of modifying the web page will be very high because of unnecessary compilation. And lastly, since you are writing web pages in JAVA it is very easy to corrupt it with business logic. Unknowingly you will introduce complexities that must be avoided.

But by not using it you are missing the object oriented programming from Web Pages. Quite bad. Now the next question, do I really need JAVA to achieve Object Oriented Programming? Answer is no. If you have heard of frameworks like JSF and ASP.NET. They have component based architecture. Components are nothing but "Encapsulations", one of the pillars of Object Oriented programming paradigm. But what about "Abstraction" and "Inheritance". Well none of the UI frameworks that support MVC pattern have an answer to it yet. This is where the framework that I have written pitches in.

Imagine if you can do something as shown below to create a web page:




<type id="address">
<textbox id="line1"/>
<textbox id="line2"/>
</type>
<type id="CustomerPage">
<abstract id="profile"/>
<address id="home"/>
<address id="office"/>
</page>
<type id="MyCustomerPage" extends="CustomerPage">
<override id="profile">
<textbox id="firstName"/>
<textbox id="lastName"/>
<textbox id="securityNumber"/>
</override>
</type>

Above sample shows all OOP principles, "Abstraction" in Customer page, "Encapsulation" in address widget and "Inheritance" in My customer page. All of it using XML syntax.

If it looks like reading something unprecedented then read more on the Ercilla Web UI framework that we have created. OOP is just one feature of Ercilla Web. There are hundreds more. Do follow the link



It's a guarantee that you have never seen something like this before.

Followers