Friday, March 20, 2009

Little about Java Server Faces (JSF)

Why JSF?

Let's first understand the reasons that initiated the JSF project and why JSF is so hot these days. There are reasons for development of new framework in-spite of many already existing technologies like JSP, Servlets, Struts etc... Using these technologies programmers directly work with HTTP request and response objects and manipulates the data. For example if user submits the registration form then programmer writes the code to get the values of each element in the form into a variable for further processing.

JSF was developed by Java Community Process(JCP). This is a community of web application experts. Java Server Faces or JSF for short, is the standard framework to simplify the process of developing web application in java.

So main purpose of developing JSF was to create a collection of APIs for the UI components with the capacity to manage their states, handle events and validation.
JSF is based on well established Model-View-Controller (MVC) design pattern.



Java Server Pages
In order to move away from this programmatic view of web page development,
the next step in the evolution brought us to Java Server Pages (JSP). These were
“special” tags that could be embedded into a web page. These tags were used by
the JSP container to generate servlets, that in turn generated the markup. So, you
had the concepts of developers who could develop JSP tags, and possibly a
different set of developers who could use the tags via JSTL (JSP Standard Tag
Libraries).
However, this still represented a “tag” based view of UI development and still
required the UI developer to understand the intricacies of HTTP protocols and to
manage state.
Thus, JSF finally brings the development of web UIs to the stage where developers
can work with visual controls that support an event model and allow visual editing
through IDEs such as Oracle JDeveloper।

JSF Core Tags Library and JSF Html Tags Library
Even a very simple page uses tags from both libraries.



<%@ taglib uri=”http://java.sun.com/jsf/core “ prefix=”f” %>

<%@ taglib uri=”http://java.sun.com/jsf/html “ prefix=”h” %>

<f:view>

<h:form>

……………

……………

</h:form>

</f:view>



All JSF Html Tags :
column creates column in a dataTable
commandButton creates button
commandLink creates link that acts like a pushbutton
dataTable creates a table control
form creates a form
graphicImage displays an image
inputHidden creates hidden field
inputSecret creates input control for password
inputText creates text input control (single line)
inputTextarea creates text input control (multiline)
message displays the most recent message for a component
messages displays all messages
outputFormat creates outputText, but formats compound messages
outputLabel creates label
outputLink creates anchor
outputText creates single line text output
panelGrid creates html table with specified number of columns
panelGroup used to group other components where the specification requires one child element
selectBooleanCheckbox creates checkbox
selectManyCheckbox creates set of checkboxes
selectManyListbox creates multiselect listbox
selectManyMenu creates multiselect menu
selectOneListbox creates single select listbox
selectOneMenu creates single select menu
selectOneRadio creates set of radio buttons

No comments:

Post a Comment