JSF basic tags

JSF framework provides a standard HTML tag library. Each tag will rendered into corresponding html output. To use these html tags we have to use the following namespaces of URI in html node. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" ><html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" > JSF Core tags are given below: JSF core tags tutorial examples. JSF inputtext html tag … Read more

Categories JSF

JSF page redirect rule

As you can see in the previous examples urls are not changed while navigating from one view page to another because JSF by default uses forward functionality instead of redirect. For page redirection we have to append faces-redirect=true at the end of the view name. Syntax: pageName?faces-redirect=truepageName?faces-redirect=true Example explanation: When “Welcome” link is clicked welcome.xhtml … Read more

Categories JSF

JSF from-action navigation rule

As we discussed in previous example JSF can resolve view based on what managed bean method returns but what if two or more managed bean methods returns the same view. To resolve such view requests JSF provides the from action navigation facility. We have to put the entries of view pages into faces-config.xml file with … Read more

Categories JSF

JSF conditional navigation rule

Conditional navigation in JSF 2 framework provides the facility to navigate based on some condition. Navigation condition can be easily handled in managed bean action method. Example explanation: In this example we have two links Test and Welcome. A parameter “pageId” is defined for the links which is linked with the “pageId” property of the … Read more

Categories JSF

JSF implicit navigation rule

An action can directly return a string or can call a managed bean method which returns a string. JSF implicit navigation when action directly returns a string. Example explanation: When “Say Hello” button is clicked it returns the “welcome” string. JSF framework embed the .xhtml at the end of the return string and display the … Read more

Categories JSF

JSF navigation rule tutorial

Navigation: Navigation in programming is way of transferring the control from one view to another. Navigation rules in JSF framework: JSF framework defines some navigation rules based on those view is render after an action is performed. A navigation rule can be defined in JSF configuration file faces-config.xml or in managed bean. JSF 2 framework … Read more

Categories JSF

JSF managed property annotation

JSF managed bean: A managed bean is a normal java bean class which contains data and business logic. A managed bean is managed by JSF framework and act as a model for JSF application. Before using a managed bean we have to configure it either in faces-config.xml file or using annotation. @ManagedProperty: The @ManagedProperty annotation … Read more

Categories JSF

JSF 2 annotations example

Let us discuss JSF annotations with below example. Example explanation: Create a managed bean class “HelloWorld.java” which is used for interacting with User Interface and business logic. HelloWorld.java contains the getter method of message property. The @ManagedBean annotation property specify the managed bean name. The @SessionScoped annotation specify the scope of the managed bean. Insert … Read more

Categories JSF

JSF ajax hello world example

Ajax: AJAX refers to Asynchronous JavaScript and XML. It provides the following features: 1.Exchanging the data between web page and server with reloading the webpage. 2.Updating the parts of web page without refreshing or reloading the whole web page. JSF use f:ajax tag to perform ajax operations. Syntax: <f:ajax execute="inputComponentId" render="outputComponentId" /><f:ajax execute="inputComponentId" render="outputComponentId" /> … Read more

Categories JSF

JSF hello world example in eclipse

Let us start JSF programming with simple hello world example. Example explanation: Create a managed bean class “HelloWorld.java” which is used for interacting with User Interface and business logic. HelloWorld.java contains the getter method of message property. Register the managed bean class into faces-config.xml and provide the details like name and scope etc. Insert the … Read more

Categories JSF