SUNDERDEEP GROUP OF INSTITUTIONS FACULTY OF ENGINEERING & TECHNOLOGY, GHAZIABAD

A Seminar Report On
JAVA SERVER FACES By PRIYA RANJAN KUMAR (0924010086) B.TECH-3RD (C.S.E-6th)

Page 1 of 21

ACKNOWLEDGEMENT
It is matter of great pleasure for me to submit this seminar report on “JAVA SERVER FACES”. I am thankful to my seminar guide Mr. Ankit Vidyarthi, Assistant Professor in C.S.E Department for his constant encouragement and able guidance. I am also thankful to Mr.A.P.Srivastava, Head of C.S.E Department for their valuable support. I take this opportunity to express my deep sense of gratitude towards those, who have helped us in various ways, for preparing my seminar. At the last but not least, I am thankful to my faculties , who had encouraged & inspired me with their blessing.
Name of student
PRIYA RANJAN KUMAR

Page 2 of 21

Title 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Introduction Released Versions Basic Concepts Processing Sequence JSF Application Building JSF Pages An Overview of JSF Component Managed Beans Navigation Standard JSF Tags Data Table Conversion & Validation Event Handling Custom Components.CONTENTS S.No. Converters. and Validators External Services Using The MyEclipse Visual JSF Designer Facelets Glossary Reference Page No. 4 4 4 5 5 6 12 13 13 15 18 17 19 19 20 20 20 21 21 Page 3 of 21 .

processing component data. In this respect it competes with and improves upon both Struts.2MR1. which is part of their JEE development path.2. This layering of APIs enables several important application use cases.0. One of the greatest advantages of JavaServer Faces technology is that it offers a clean separation between behavior and presentation. the JavaServer Faces APIs are layered directly on top of the Servlet API. released in mid-2008. converters.2. There is also an updated version called JSF 1. including a reference implementation by Sun. During late 2008. released in January 2009. and it was downloaded from the Apache site. Basic Concepts For the most part. validating user input. Another important goal of JavaServer Faces is to leverage familiar UI-component and webtier concepts without limiting you to a particular scripting technology or markup language. Released Versions In early 2008.Introduction JavaServer Faces (JSF) is a successor to JavaServer Pages. such as custom components A deployment descriptor (a web. This is shipped by Sun with their “Mojarra” release. and generating output for various client devices. which was released in early 2008. we switched to the JSF 1. validators. There are several implementations of JSF available. a JavaServer Faces application is like any other Java web application. The jar size is about 800K. we began using the Apache implementation: myfaces-1. creating your own custom components directly from the component classes. or listeners. which are JavaBeans components that define properties and functions for UI components on a page An application configuration resource file. JSF is a full web application framework that allows you to build web applications that implement the finer-grained separation of behavior and presentation that is traditionally offered by client-side UI architectures.2 implementation provided by Sun called JSF 1. Although JavaServer Faces includes a JSP custom tag library for representing components on a JSP page. A set of custom tags for representing custom objects on the page Page 4 of 21 . such as using another presentation technology instead of JSP pages.xml file) Possibly a set of custom objects created by the application developer. JavaServer Faces technology provides a rich architecture for managing component state. . which is shipped with JBoss 4. which defines page navigation rules and configures beans and other custom objects. These objects might include custom components. It also competes with the Web MVC facility within Spring.2. A typical JavaServer Faces application includes the following pieces:       A set of JSP pages (although you are not limited to using JSP pages as your presentation technology) A set of backing beans.3 and used by Seam 2.2MR2. Most importantly. and handling events.2.

can be parsed into a tree of components. the term “view” is quite different from the Struts concept. A typical example would be validation. For instance. In JSF.Processing Sequence The diagram above compares the processing sequence of Struts and JSF. as it means the JSF file that has view annotation and hence. the framework dispatches to the view. Example JSF Application MyEclipse has a browser for the navigation sequence that looks like: Page 5 of 21 . which can run business logic. The components are then “executed”. the response could be generated after the first pass by the components. However.

With the view and form tags added. a text fields. so you will be working with the form tag quite often. buttons. All UI component tags that represent editable components (such as text fields and menus) must be nested inside the form tag. The greeting.sun. There are visual display elements for labels. which is defined in the core tag library. our page looks like this (minus the HTML and HEAD tags): <%@taglib uri="http://java.sun. and inputnumber. Adding the view and form Tags All JavaServer Faces pages are represented by a tree of components.com/jsf/core" prefix="f" %> <f:view> <h:form id="helloForm1"> </h:form> </f:view> Adding a Label Component The outputText tag represents a label.com/jsf/html" prefix="h" %> <%@taglib uri="http://java.sun. you need to give your pages access to the two standard JSF tag libraries.com/jsf/core" prefix="f" %> The first taglib declaration declares the HTML component tag library with a prefix.faces. graphicImage. The view tag represents the root of the view. Building up JSF pages. and contain visual display components within those. The other tag displays the number 10: Page 6 of 21 .The JSF pages themselves (called out as success. Feature by Feature Declaring the Tag Libraries In order to use JavaServer Faces components in JSP pages or other files.xml such that JSF files are sent to the javax.com/jsf/html" prefix="h" %> <%@taglib uri="http://java. In the case of the greeting. called a view.faces. Setting up the web. The most interesting pages are those which are input forms. One of the tags displays the number 0. This changes if Facelets is being used.faces in the above). using taglib declarations: <%@taglib uri="http://java.webapp. contain a subregion on the page called the view. and message. All JavaServer Faces component tags must be inside of a view tag. h (for HTML).jsp page has two outputText tags. commandButton.FacesServlet.xml File You must configure web. the HTML component tag library and the core tag library.sun. otherwise the page will produce the error message “Cannot find FacesContext” when any JSF tags are carried out. some of the tags contained in the form are outputText. inputText.jsp page.

Can you guess it?</h2> <h:graphicImage id="waveImg" url="/wave. you need to configure them in the application configuration resource file so that the JavaServer Faces implementation can automatically create new instances of the beans whenever they are needed.gif" /> </h:form> </f:view> Controlling Rendering of a Component All JSF components accept an optional attribute called “render”.<h:outputText lang="en_US" value="#{userNumberBean. A page author can use the unified EL to access one of the bean‟s properties.com/jsf/html" prefix="h" %> <%@taglib uri="http://java. With the addition of the outputText tags (along with some static text).sun.sun. The default is “true”.sun.med. My name is Duke. I’m thinking of a number from <h:outputText lang="en_US" value="#{userNumberBean. like this: <h:outputText value="#{userNumberBean.com/jsf/core" prefix="f" %> <f:view> <h:form id="helloForm1"> <h2>Hi.minimum}"/> Adding an Image To display images on a page.minimum}"/> to <h:outputText value="#{userNumberBean. which indicates if the component should be showed or skipped over at rendering time. Page 7 of 21 . Let‟s add Duke to the page using a graphicImage tag: <%@taglib uri="http://java. you use the graphicImage tag. My name is Duke.com/jsf/html" prefix="h" %> <%@taglib uri="http://java. The url attribute of the tag specifies the path to the image file.maximum}"/> The value attributes of the tags get the values from the minimum and maximum properties of userNumberBean using value expressions.sun. I’m thinking of a number from <h:outputText lang="en_US" value="#{UserNumberBean.maximum}"/>. Can you guess it?</h2> </h:form> </f:view> Adding Managed Bean Declarations After developing the backing beans to be used in the application. which are used to reference data stored in other objects.com/jsf/core" prefix="f" %> <f:view> <h:form id="helloForm1"> <h2>Hi.minimum}"/> to <h:outputText value="#{UserNumberBean.minimum}"/> <h:outputText value="#{userNumberBean.maximum}"/>. the greeting page looks like the following: <%@taglib uri="http://java. such as beans.

The table below lists all the standard validator classes and the tags that allow you to use the validators from the page. In the case of the greeting page. This validator checks whether the component‟s local data is within a certain range.maximum}"/>. So.Since JSF itself has no facility for conditional logic (this is supplied by the View Definition facilities. the page author registers a LongRangeValidator onto the text field. you need to validate the number the user enters into the text field.minimum}"/> to <h:outputText value="#{userNumberBean. you add a validateLongRange tag inside the inputText tag. defined by the validateLongRange tag‟s minimum and maximum attributes. Registering a Validator on a Text Field By nesting the validateLongRange tag within a text field‟s component‟s tag.minimum} and #{UserNumberBean.maximum}" /> </h:inputText> </h:form> </f:view> JavaServer Faces technology provides a set of standard classes and associated tags that page authors and application developers can use to validate a component‟s data. After adding the validateLongRange tag. Can you guess it?</h2> <h:graphicImage id="waveImg" url="/wave. My name is Duke.gif" /> <h:inputText id="userNo" label="User Number" value="#{userNumberBean. I’m thinking of a number from <h:outputText lang="en_US" value="#{userNumberBean.sun. Page 8 of 21 . use of the “render” attribute and an EL expression for the value is only way to control conditional content or layout of the page. The value must be floating-point or convertible to floating-point.userNumber}"> <f:validateLongRange minimum="#{userNumberBean.maximum}.com/jsf/html" prefix="h" %> <%@taglib uri="http://java. the page looks like this: <%@taglib uri="http://java.com/jsf/core" prefix="f" %> <f:view> <h:form id="helloForm1"> <h2>Hi. The maximum and minimum attributes of the validateLongRange tag get their values from the minimum and maximum properties of UserNumberBean using the value expressions #{UserNumberBean. such as JSP or Facelets).minimum}" maximum="#{userNumberBean.med. Validator Class Tag Function DoubleRangeValidator validateDoubleRange Checks whether the local value of a component is within a certain range.sun.

The value must be a java. The value must be any numeric type or String that can be converted to a long. you add a converterMessage attribute on the inputText tag. he or she would see the following error message:User Number: ’m’ must be a number between -2147483648 and 2147483647 Example: 9346 This is wrong because the field really only accepts values from 0 through 10. It‟s for attribute refers to the component whose value failed validation. LongRangeValidator validateLongRange The specification of validation in the page provides much of the justification for the JSF concepts. The error message displays wherever you place the message tag on the page. This attribute references the custom error message: <h:inputText id="userNo" label="User Number" value="#{userNumberBean. The application architect needs to define the message in the resource bundle and configure the resource bundle. whose tag is registered on the text field component. layout.userNoConvert}"> .LengthValidator validateLength Checks whether the length of a component’s local value is within a certain range. Displaying Error Messages A message tag is used to display error messages on a page when data conversion or validation fails after the user submits the form. in this case the userNo component represented by the inputText tag in the greeting. </h:inputText> The expression that converterMessage uses references the userNoConvert key of the ErrMsg resource bundle. if a user were to enter a letter into the text field on greeting.jsp displays an error message if the data entered in the field does not comply with the rules specified by the LongRangeValidator implementation.String. and also handle persistence. For example. Checks whether the local value of a component is within a certain range.sun.lang.com/jsf/html" prefix="h" %> Page 9 of 21 . The message tag‟s style attribute allows you to specify the formatting style for the message text.jsp page. The message tag in greeting. To override this message. This can allow the business logic to perform just that.userNumber}" converterMessage="#{ErrMsg. JSF allows for neardeclarative specification of web page in terms of components. input management. Rather than having all business logic run in the action. One typically puts the message tag near the top or bottom of the page: <%@taglib uri="http://java. where those components can specify presentation. In some cases. you might need to override the standard message...jsp. and validation. Adding a Custom Message JavaServer Faces technology provides standard error messages that display on the page when conversion or validation fails.

font-family: ’New Century Schoolbook’. Defining Page Navigation Defining page navigation involves determining which page to go to after the user clicks a button or a hyperlink. Assuming you have also done the response. font-style: oblique.com/jsf/core" prefix="f" %> <f:view> <h:form id="helloForm1"> <h2>Hi.gif" /> <h:inputText id="userNo" label="User Number" value="#{userNumberBean.maximum}"/>. My name is Duke. Here is one of the navigation rules defined for the guessNumber example: <navigation-rule> <from-view-id>/greeting.jsp</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/greeting.minimum}"/> to <h:outputText value="#{userNumberBean.jsp</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <from-view-id>/response.jsp page.maximum}" /> </h:inputText> <h:commandButton id="submit" action="success" value="Submit" /> <h:message showSummary="true" showDetail="false" style="color: red.sun. Navigation for the application is defined in the application configuration resource file using a powerful rule-based system.jsp</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/response. Can you guess it?</h2> <h:graphicImage id="waveImg" url="/wave. text-decoration: overline" id="errors1" for="userNo"/> </h:form> </f:view> Now you have completed the greeting page.userNoConvert}"> <f:validateLongRange minimum="#{userNumberBean.med. I’m thinking of a number from <h:outputText lang="en_US" value="#{userNumberBean. you can move on to defining the page navigation rules.jsp</to-view-id> </navigation-case> Page 10 of 21 .userNumber}" converterMessage="#{ErrMsg. serif.minimum}" maximum="#{userNumberBean.<%@taglib uri="http://java.

userNoConvert}"> . </h:inputText> Here is the userNumber backing bean property that maps to the data for the userNo component: Integer userNumber = null. . Here is the inputText tag again: <h:inputText id="userNo" label="User Number" value="#{UserNumberBean.jsp if the navigation system is given a logical outcome of success. the logical outcome is defined by the action attribute of the UICommand component that submits the form: <h:commandButton id="submit" action="success" value="Submit" /> Configuring Error Messages In case the standard error messages don‟t meet your needs. Developing the Beans Developing beans is one responsibility of the application developer. Page 11 of 21 . you can create new ones in resource bundles and configure the resource bundles in your application configuration resource file. The guessNumber example has one custom converter message. The resource bundle is configured in the application configuration file: <application> <resource-bundle> <base-name>guessNumber..The page author binds a component‟s value to a bean property using the component tag‟s value attribute to refer to the property..ApplicationMessages</base-name> <var>ErrMsg</var> </resource-bundle> </application> The base-name element indicates the fully-qualified name of the resource bundle.. A typical JavaServer Faces application couples a backing bean with each page in the application.</navigation-rule> This navigation rule states that when the button on the greeting page is clicked the application will navigate to response. Recall that the userNo component on the greeting.userNumber}"> . In the case of the Guess Number example. </h:inputText> The expression on the converterMessage attribute references the userNoConvert key of the ErrMsg resource bundle.userNumber}" converterMessage="#{ErrMsg.jsp page references the userNumber property of userNumberBean: <h:inputText id="userNo" label="User Number" value="#{userNumberBean.. The backing bean defines properties and methods that are associated with the UI components used on the page.. The var element indicates the name by which page authors refer to the resource bundle with the expression language..

For instance a set of radio buttons are described through an h:selectOneRadio element. and stylesheet rule references. as all JavaBeans components must do. The JSF components are loosely arranged in a hierarchy. most include the DHTML event handlers. } public Integer getUserNumber() { return userNumber. } public String getResponse() { if (userNumber != null && userNumber.public void setUserNumber(Integer user_number) { userNumber = user_number. conditional renderers. They have names that are similar to their HTML counterpart. Several of the more complex JSF components operate like Swing or AWT components: they have a data model that they work with. in that many have common attributes. which takes child elements describing the choices. "+userNumber+" is incorrect. and then they generate HTML <select> and <option> tags from this information. and then generate an HTML table populated with <input type=‟radio‟> elements.compareTo(randomInt) == 0) { return "Yay! You got it!". a backing bean class also defines a set of UI component properties and possibly a set of methods that perform functions for a component. Page 12 of 21 . but are sometimes higher level. } else { return "Sorry. For instance.". such as one that provides data for a select list. } } In addition to defining a no-arg constructor. The latter allows you to use HTML attributes that were not designed into the component‟s behavior. and HTML pass-through attributes. Each of the component properties can be bound to one of the following:  A component‟s value  A component instance  A converter instance  A listener instance  A validator instance The most common functions that backing bean methods perform include the following:  Validating a component‟s data  Handling an event fired by a component  All business logic  Performing processing to determine the next page to which the application must navigate An Overview of the JSF Components There are about 40 primary components.

and it must match the name of a page flow in the navigation rules.xml </param-value> </context-param> Chaining beans: at initialization time you can wire beans together by means of references that are stored into the beans (a form of dependency injection). The loading and initialization information can include defining names." The text then goes onto suggest on how to do this in your web. The action to be carried out is based on the input values as well as a name string. This is a good time to review some approaches to organizing and dividing up configuration files. This particular method is useful when you wish to split up a large JSF application into manageable pieces. which is the name of a method to invoke to determine the next action name.xml file with the following example: <context-param> <param-name>javax. /WEB-INF/faces-config2.application.value fields on the beans.ProblemBean</value-class> <value>#{problem1}</value> <value>#{problem2}</value> </list-entries> </managed-property> Navigation Static navigation: in a simple web application. You specify an outcome. classes. such as “#{loginController. A JSF implementation will next "look for a context initialization parameter named javax. as we saw in the examples above.xml file for one or more JSF configurations that should be loaded.xml.Managed Beans Beans are loaded and initialized based on information the faces-config file or other bean configuration files that can be specified. Dynamic navigation: this occurs in most real-world web applications. as in each action you code the name of the next page to bring up.application. Page 13 of 21 .verifyUser}”.faces. The submit button must have a method expression. navigation is static.CONFIG_FILES</paramname> <param-value> /WEB-INF/faces-config1. and initialization of scalar.faces.corejsf. The value of this parameter is a comma delimited list of context relative resource paths (each starting with /).CONFIG_FILES in the web. such as “login”.and list. These are shown as: <managed-property> <property-name>problems</property-name> <list-entries> <value-class>com.

in which the correctness or non-correctness of the user‟s input determine if we should go to a success page or a try-again page.faces. if you add <redirect/> after the to-view-id.This is demonstrated in the QuizBean. the JSF implementation must process zero or more application configuration resources. The precise rules regarding these config files is: at application startup time. Check for the existence of a web application configuration resource named “/WEBINF/faces-config. The page navigation rules can also be located in a file called “navigation. before any requests are processed. it is similar to the redirect facility in a Struts action. If it exists. and load it if the resource exists. Caution. Advanced navigation issues include the use of redirect and wildcards in the navigation specification file(s). located according to the following algorithm:  Search for all resources named “META-INF/faces-config.xml”. They state: As long as you stay away from wildcards and from-action element. and load each of the specified resources. you will not need to know about the details of the navigation algorithms. Check for the existence of a context initialization parameter named javax.   Naturally. For instance.xml” in the ServletContext resource paths for this web application. with the redirect option. treat it as a comma-delimited list of context relative resource paths (starting with a “/”). Sample navigation paths through the Quiz program. which will be loaded after the faces-config. the authors recommend that you do not create tricky navigation rules. Page 14 of 21 .CONFIG_FILES.xml”.xml file. request scope data is lost. and load each as a JSF configuration resource (in reverse order of the order in which they are returned by getResources() on the current Thread‟s ContextClassLoader).

actionListener. Standard JSF Tags There are some 45 tags in the combination of core and HTML. They can be broken down as follows:  The Core tags are typically something that you add to an HTML object. verbatim (a kind of literal) HTML section notes: These include form. similar to an HTML table With Facelets (unlike regular JSF) you don‟t have to put all your text elements into an h:outputText element. etc. such as onmousedown. etc. Textfields and Textareas notes: This covers a number of i/o facilities.  The HTML files build the basic HTML elements such as labels and text fields  Form tags – these are the subset of tags that can be used inside a form. such as controlling the formatting of text. etc. just more compact. so this section is actually short. the facilities for hidden fields. such as textfield. we have had to expand upon the standard navigation rules. outputText. disabled. converter.  Textfields and text areas – for input and output  Buttons and links – for action-taking  Selection tags – for generating selection lists  Messages – for formatting message display. subview. validator. the validation rules. and then describes how JavaScript can be integrated to carry out client-side processing. selectOneMenu. It describes the attribute of the form tag. It would be hard for a non-HTML person to follow some of the discussion. commandButton. validator. Core section notes: View. valueChange Listener. such as validation or other facet. Hence our approach is to use a central dispatcher that also causes the ConfigurationManager to read the configuration file. such as error messages  Panels – for special layout. graphicImage.However. and then use a page forwarding rule that is wild-carded to work from any other screen. etc.0 pass-through attributes. such as alt. as the JSF tags don‟t really make things easier for the designer. such as styleClass. There are also a set of DHTML event attributes. though if you want to vary the context programmatically. commandLink. Form section notes: All of the pieces of the form are described elsewhere. the number of rows and cols in a text area. selectManyListbox. Button and Links notes: Page 15 of 21 . There are also a set of HTML 4. because Incra uses page forwarding specifications that are expressed in the module configuration rules. accept. and more. then you must. There are common attributes for all HTML tags. id.

They can also take command parameters. and create a containing table. such as: private static SelectItem[] condimentItems = { new SelectItem(1. Map paramMap = ec. such as “#{productManager. <h:selectOneListbox> and <h:selectManyListbox> The children can be specified using <f:selectItem> tags.newProduct}”. They can take an action expression. such as the following: <ui:repeat value="#{categoryManager. use the following: FacesContext fc = FacesContext. “Cheese”). new SelectItem(3.name}"> <f:param name="categoryId" value="#{category.getCurrentInstance().getExternalContext(). String categoryIdStr = (String) paramMap. list.selectCategory}" value="#{category.mode}”> <f:selectItem itemLabel="Alpha" itemValue="0" /> <f:selectItem itemLabel="Beta" itemValue="1" /> <f:selectItem itemLabel="Gamma" itemValue="2" /> </h:selectOneRadio> This is bound to the getter/setter on backing bean „form‟ called “mode”.stack}" var="car"> <h:commandLink action="#{categoryManager. “Pickle”). new SelectItem(2. Radio button and Checkbox notes: Two JSF tags represent checkboxes: h:selectBooleanCheckbox. Selection drop-down.condiments}”> <f:selectItems value=”#{formManager. These include a layout specification.condimentItems is a collection of instances of the SelectItem interface.get("categoryId"). or you can create the choices programmatically using the following <h: <h:selectOneListbox value=”#{formManager. and combo-box notes: Use the tags <h:selectOneMenu>.getRequestParameterMap(). The f:selectItems value attribute must be a value expression that produces one of the following:  A single SelectItem instance  A collection of SelectItem instances  An array of SelectItem instances  A map whose entries represent SelectItem labels and values Page 16 of 21 .id}" /> </h:commandLink> <h:outputText value=" > " /> </ui:repeat> To fetch the parameters in your action code. “Mustard”) }. Here is an example: selectOneRadio value=”#{form. ExternalContext ec = fc.condimentItems}”> </h:selectOneListbox> Where the value of formManager.The commandButton and commandLink tags are very commonly used. which would typically be an integer value. and h:selectManyCheckbox.

and specific JSF tags are used to fetch from this queue and display the results. we are collecting the attributes display here: Page 17 of 21 . There is also a tag called outputLink.This is a pretty powerful system for generating procedural selection lists. items with description fields. There are further facilities for creating disabled items. There are layout modes for tables and lists. This part contains more examples of radio button and checkbox creation tags. there are different warning levels of messages. and provides automated layout similar to that in Swing or SWT. any object may add a message to the output queue. such as right-click context menus. Because it will get used over and over. and item groups. Messages notes: During the JSF processing lifecycle. and there are global and local messages. but instead it renders to a more simple <a> and </a> tag pair wrapped around some content. which doesn‟t generate the JavaScript event processing that goes with the tag. Panel notes: The panelGrid tag allows you to avoid using HTML tables. The tags called menus are really about dynamic popups. How does this differ from commandLink? It is basically a simpler version of commandLink.

Page 18 of 21 . Validators are similar to converters.name}" /> </h:column> </h:dataTable> </h:form> <h:messages/> </f:view> First of all. Except for the border=”1” attribute on the h:dataTable element. Some of the more challenging aspects of data types are how to assign id‟s. while the converted values are in the backing bean. In general. Conversion and Validation Converting strings entered on an HTML form and validating their values is a key part of web applications. The original input is represented by objects of the class UI Input. etc. the code will create unique id‟s for you. These classes can specify the class to be used for rows. a set of elements.students}" var="line"> <h:column> <h:outputText value="#{line. etc. in that they are placed inside the inputText tag or a similar tag. Data Tables A data table is described from a source. such as a number being between two limits. Options in the table facility include controls for paging.amount}”> <f:convertNumber minFractionDigits=”2” /> </h:inputText> The main tags are convertNumber and convertDateTime. This is supported because the system is keeping track of the original input and the converted values. The errors are shown with the <h:message> tag. These will be in a tree structure of names such as jid_04:jid_06. the configuration of a datatable is driven by a set of elements. and a set of column specifications. such as “column”. or a string being a specific length or a range of lengths.The children of a panel grid are wrapped in panel Group elements. Conversion errors will cause the page to be redisplayed with the user‟s inputs shown. except that they specify a condition to check for. It is now possible to override the conversion or validation message that is displayed to the user on a per-instance basis. all of the formatting is controlled by CSS classes. and “facet”. Here is a table configuration example: <f:view> <h:form> <h:dataTable border="1" value="#{StudentBean. JSF goes we can attach a converter to an input field. For example: <h:inputText value=”#{payment. columns. each of which have several options controlled through attributes.

and then sent to listeners for that phase‟s events. etc.Event Handling JSF uses events in the same sense as Swing or Windows: there are events for submits/posts.There are six phases:  Restore View  Apply Request Values  Process Validations  Update Model Values  Invoke Application  Render Response Events are queued during each phase. and a command can trigger a number of such events. which looks like: Page 19 of 21 . Phase Events allow you to interpose in the processing lifecycle. such as processing a request. value changes. such as jump directly to “renderResponse”. Understanding the life cycle is critical here . rendering the output. The event listeners can also change the lifecycle. and Validators It is here that we are introduced to the JSF component class hierarchy. Custom Components. Converters. the events break down to:  Value change events – a bean contents update has occurred  Action events – triggered by command components  Phase change events – this means that we have started or finished a part of the lifecycle. etc. Immediate input events are used to inform a component of a change to a value in a backing bean. Action events are generated by commands. Hence.

There is another set of classes that describe converters. such as database. validators and error handling from validation. It solves all the ugliness of using JSF with JSP 2. dataTables and panelGrid. The first and the most important thing is that it makes the future JSP 2. For web services.g. Facelets makes JSP pages Page 20 of 21 . External Services “External Services” means external content sources. available on any JSP 2. or a web service invocation. a Tag class. which is also provided within GlassFish.Once a component is created. and rendering of advanced components. An immediate benefit is the significant reduction on JSP page size after the removal of the alignment code between JSF and JSP. There is no mention on Axis or X Fire.0. especially the Unified Expression Language. it becomes a new tag like the JSP custom tags. and in fact is Render class. Within the Design view there is an embedded toolbar and palette that can be used Facelets Facelets is a lightweight.1 features. or a news reader. e. Using the MyEclipse Visual JSF Designer While MyEclipse has offered a Visual JSP Designer in the past.5 and later offers many new features to JSF developers like dynamic analysis of build path to determine the taglibs available on the palette. the advanced Visual JSF designer now available in MyEclipse 5. Tapestry-like web framework backed by JSF technology.0 platform. they are proposing use of the Java Web Services Developer Pack from Sun. and a UI class.

com www." which enables you to declare JSF UI components as ordinary HTML tags: Facelets has several compelling features:  Composition components (like include files.wikipedia. comes with MyFaces Facelets – replacement for JSP.more designer friendly through a Tapestry-style attribute "jsfc.google. includes EJB3.org http://java.2  Designer-friendly page development  Creating component libraries Glossary JSF – JavaServer Faces JEE5 – the newest Java App Server spec.sun. integrated well with JSP Reference www. JSF etc.com/javaee/javaserverfaces Page 21 of 21 . MyFaces – Apache‟s JSF impl. completely replaces Sun‟s ref impl for JSF Tomahawk – Apache‟s set of components to extend JSF. interprets XML instead of JSP files to produce web pages. or a macro processor)  Templating (like Tiles)  Use of JSTL 1.