Tuesday, March 24, 2009

JSF Renderers

Each of the JSF tag gives rise to an associated component.
A renderer is a type of class that is responsible for encoding and decoding components.

Encoding:

For example: Suppose we have used h:inputText tag . So the renderer of the component associated with this tag produces the following output:

<input type=”text” name=”ID” value=”current_value”/>


Additional User-Interface Component Libraries

Because of the richness and flexibility of the JSF API, many Java developers are beginning to create new JSF Component libraries and implementations. Oracle's ADF Faces is a fully compliant JSF component library which offers a broad set of enhanced UI Components for JSF application development. These include multiple renderers per client type, advanced tables, color and date pickers along with a host of general components such as menus, command buttons, shuttle choosers and progress meters.

MyFaces is an example of a new JSF UI Component Library being offered as an Open Source project through Apache. Myfaces also serves as an enhancement to the JSF base UI components in that they also have more extensive UI capabilities such as integrated Tiles support, Javascript enabled menus and Tree controls.


Writing JSF components can be a difficult task, but using them is as simple as a call to a tag. And that is exactly the strength and coolness of Faces.

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