Originally posted by kundan varma: Hi All, What is the benefit of using JSF instead of struts?? Thanks, kundan
Here is a simple list that I have compiled from various sources on the web:
Struts does not provide the built-in UI component model. And because of that, it does not support UI component event model, nor state management of UI components. Since Struts is more or less tied up with HTML, it does not support the independence between UI components and a particular renderer. Both JSF and Struts developers implement web pages with JSP custom tags. But Struts tags generate HTML directly, whereas JSF tags represent a component and renderer that generate HTML. That key difference makes it easy to adapt JSF applications to alternative display technologies. �Custom components � JSF makes it relatively easy to combine complex GUIs into a single manageable component; Struts does not �Support for other display technologies � JSF is not limited to HTML and HTTP; Struts is �Access to beans by name � JSF lets you assign names to beans, then you refer to them by name in the forms. Struts has a complex process with several levels of indirection where you have to remember which form is the input for which action. � In Struts, The ActionForm bean is passed to the Action and the action can do with it what it wants. In JSF, the ValueBinding mechanism exposes the entire managed-bean namespace to anywhere in the app that needs it. �Expression language � The JSF expression language is more concise and powerful than the Struts bean:write tag. �Simpler controller and bean definitions � JSF does not require your controller and bean classes to extend any particular parent class (e.g., Action) or use any particular method (e.g., execute). Struts does. �Simpler config file and overall structure � The jsf-config.xml file is much easier to use than is the struts-config.xml file. In general, JSF is simpler. �More powerful potential tool support � The orientation around GUI controls and their handlers opens the possibility of simple to use, drag-and-drop IDEs. �Flexibility � Faces supports a �code behind files� concept, Struts does not. �Foundation Technologies � JSF will be in J2EE 1.5 � JSF 1.1 applications can run in a Portlet, Struts applications cannot. �Components and Events � Struts has no notion of components. Thus it has no notion of component state. JSF has an excellent state management story supporting saving the state in the client or on the server. � JSF brings a JavaBeans like event model to the web, Struts has nothing similar to this. � JSF has dataTable support, struts does not. � JSF was intended from the beginning to create a market for third party components. �Conversion and Validation � Both support type Conversion, but the Faces story is more powerful � Struts Action class tightly coupled to ActionServlet, can call its methods. Nothing in JSF calls the FacesServlet.