JSF Introduction

Copyright © 2000-2007 Liferay, Inc. All Rights Reserved.
No material may be reproduced electronically or in print without written permission from Liferay, Inc.

Why JSF vs.Objective The goal of this tutorial is to create a Java Server Faces (JSF) Portlet within Liferay 1. What is JSF? 2. Struts? .

Key Concepts What are the main differences between a JSF Portlet and a JSP Portlet? – JSF follows the MVC pattern. good for rapid prototyping . and provides a framework to develop robust web applications – JSP is a model 1 pattern.

JavaServer Faces Technology FAQ.What is JSF? JavaServer Faces technology is a framework for building user interfaces for web applications. JavaServer Faces technology includes: • A set of APIs for: representing UI components and managing their state. defining page navigation. • A JavaServer Pages (JSP) custom tag library for expressing a JavaServer Faces interface within a JSP page.” Reference: Sun Developer Network.sun.com/javaee/javaserverfaces/reference/faqs/index.html . handling events and input validation. http://java. and supporting internationalization and accessibility.

• Highly Customizable Every level of the JSF life cycle is customizable. Consistent development means that the code is easier to maintain. JSF is not tied to a presentation layer and does not have to use the HTTP protocol. Elements on the page can be traversed in the POJO. • Enforces Best Practices Everything is encapsulated in a component.What are the benefits of JSF? • • Container Agnostic Development is the same whether your application is servlet or portlet based Tree-based Component Model All components on the JSP page (JSF tags) are persisted in memory This gives you the ability to insert a table or a button in the middle of a page at runtime rather than code it in your JSP. . For example.

com/javaee/javaserverfaces/reference/faqs/index. and developers can use certain features of both frameworks in a single application. http://java.html . JavaServer Faces technology is a user-interface framework for Java web applications. It is focused on the view tier of an MVCbased architecture. however each framework has its advantages.sun. The Struts and JavaServer Faces technology frameworks do have some overlapping functionality. Reference: Sun Developer Network.What are the key differences between JSF and Struts? Struts is an open-source Java web application framework whose architecture is based on the Model-View-Controller design pattern in which requests are routed through a controller that provides overall application management and dispatches the requests to application components. JavaServer Faces Technology FAQ.

Advantages of JSF over Struts The main advantage of JSF is its flexible. and more complex components. including simple components. Reference: Sun Developer Network. such as scrollable data tables.html . http://java.sun. An event and listener model that defines how to handle events generated by activating a component. such as input fields.com/javaee/javaserverfaces/reference/faqs/index. such as what to do when a user clicks a button. extensible UI component model which includes: A standard component API for specifying the state and behavior of a wide range of components. JavaServer Faces Technology FAQ. A separate rendering model that defines how to render the components in various ways. a component used for selecting an item from a list can be rendered as a menu or a set of radio buttons. For example.

html . http://java. JavaServer Faces technology allows you to extend the standard set of components and create entirely new components.JavaServer Faces separates the definition of a component from its rendering. JavaServer Faces Technology FAQ.sun.com/javaee/javaserverfaces/reference/faqs/index. While Struts does have a useful tag library for rendering components on the page. such as a WML client. Struts has no notion of server-side components. <h:commandButton action="#{myBean.addBook}"> calls myBean. which means that it has no event model for responding to component events and no facility for saving and restoring component state. The controller logic is implemented in POJOs so there is no need to implement Struts’ processAction or execute methods. JSF provides tags that specify which method will be called.addBook() Reference: Sun Developer Network. these components have no object representation on the server and they can only be rendered to an HTML client. further simplifying the controller logic. so you can render your components in different ways or even to different clients.

1 .1.1 01/17/2007 4.2.Revision History Edward Shin James Min 8/28/2006 Updated for Liferay 4.

Sign up to vote on this title
UsefulNot useful