Advertisment

JSF or Struts, which way to go?

author-image
CIOL Bureau
Updated On
New Update

The JavaServer Faces





JavaServer Faces (JSF) technology is Sun's solution for building user interfaces for JavaServer applications. It provides the developers with a set of UI components that can be dragged and dropped to create a Web page. These components can talk to a backend data source and can connect events generated at the client side with event handlers residing at the server.

Advertisment

Programming high-quality Web-based user interfaces has always been a big challenge for developers as there is no concept of components in Web; event handling is a problem, as it has no notion of state. This technology promises to ease the life of Web developers by saving them time and enabling them to build powerful Web-based GUIs.

A JavaServer Faces application behaves like a servlet or a Java Server Page(JSP) application running on a container that is compatible with the J2EE platform. Web controls like text fields, forms, buttons, tables, checkboxes and several other such controls can be created in a JSF UI.

JSF Features

Advertisment

Sun's JSF technology boasts of features like managed bean facility, validation facility, a rich and extensible component library, pluggable render kits, navigation response on specific requests, preserving application's state and conversion model, to name a few.

Behind the scenes





A JSP page with JavaServer Face components builds a component tree in the server's memory. This tree has a component tag corresponding to each UIComponent instance in the interface. This component tree handles the request-response between the Web-based UI and server. For eg. on click of a button an event gets generated, this event is handled by the Java Server Face lifecycle and an appropriate response gets generated.

Other Technologies





Java Server Faces is not the only technology that can handle Web-based UI, other solutions operating in the same space are Struts, Tapestry and Velocity. Out of all of them Apache Software Foundation's (ASF) Struts is around for sometime now and has been the most popular choice amongst developers of Web-based GUI.

Advertisment

JSF or Struts

The debate is still on. Some developers are confused which way to go, some have their loyalties with Struts and think that JSF is no better, however there are some who have been working on Struts but want to experiment with JSF also.

Some positives to JSF are that it is standard based and hence will continue to evolve, it has a rich component model, and can be used in conjunction with the Struts framework. According to a Java enthusiast JSF provides all the functionality that Struts provides and more, where JSF currently lags behind are custom tags, which will grow with time as the technology becomes more mature.

Advertisment

However, there are few others who are all for the open source solution Struts, and feel that Sun could have done a better job with JSF. According to this camp JSF is not as extensible as Struts is and its Validation Framework also provides only server side validation without any facility for generating client-side validation code. 'JSF should have subsumed all of the capability provided by popular frameworks such as Struts and offered even more,' says one developer from this camp. This group also debates that making JSF extensible to Struts has complicated things even more because it will not be easy to use both together and will cause increased complexities.

This seems to be another fight between open source and proprietary software and time will tell, which way the scale turns. Or should we say 'developers' would decide the fate.

 



 



 



tech-news