JSF 2 @ConversationScoped Example

JSF-Thumbnail

JavaServer Faces has been coming with different kinds of scopes; scopes that already used for defining the Managed Beans. Most of the JSF developers were familiar with scopes like Request, View, Session & Application, but newly added scopes such Conversation, View, Custom and newly for JSF 2.2 Flow haven’t gained a widely range of discussion on the internet […]

JSF 2 ViewScoped Example

JSF-Thumbnail

View scope was added in the JSF 2.0. A bean in view scope persists while the same JSF view (page) is re displayed. Once the user has navigated into another view the viewscoped bean goes out of scope. If your application has a page has been getting re displayed, then you can put the data […]

JSF 2 Flash Scope Example

JSF-Thumbnail

To minimize session scope bloat, it makes sense to use scope of request as much as possible. Without the redirect element, you can use request scoped beans that are shown in the next view. However, consider what happens with a redirect. The client sends a request to the server. The request scope map is populated […]

JSF 2 UI Debug Example

JSF-Thumbnail

When you place the ui:debug tag in a Facelets page, a debug component is added to the component tree for that tag. If the user types a hotkey, which by default is CTRL+SHIFT+d, JSF opens a window and display the state of the component tree and the application’s scoped variables. You can click on the Component Tree […]

JSF 2 UI Remove Example

JSF-Thumbnail

Sometimes, to find out which part of a jsf view causes a stack trace, you may want to use the time-honored divide-and-conquer strategy of commenting out parts of the page to isolate the offending component. Somewhat surprisingly, the XML comments <!– … –> are not useful for this purpose for example when you comment out a […]

JSF 2 Dynamic Target View ID (to-view-id) Example

JSF-Thumbnail

The to-view-id element can be a value expression, in which case it is evaluated. The result is used as the view ID. This type of providing of to-view-id isn’t implemented before JSF 2.0. This Also Read: JSF 2 Tutorials JSF Tutorials Introduction to JSF 1. Managed Bean IndexBean.java 2. The views login.xhtml welcome.xhtml expensesView.xhtml 3. Faces Configuration File faces-config.xml […]

JSF 2 Wildcard Navigation Rule Example

JSF-Thumbnail

In JSF you can use wildcard in the from-view-id element of a navigation rule, that is the rule applies to all pages that start with the prefix /somePrefix. Only a single (*) is allowed, and it must be at the end of the ID string. If there are multiple matching wildcard rules, the longest match is taken. The using of […]

JSF 2 Redirect Navigation Example

JSF-Thumbnail

You can configure the JSF configuration to redirect to a new view. Then the JSF implementation sends an HTTP redirect to the client. The redirect response tells the client which URL to use for the next page. The client then makes a GET request to that URL. Redirecting could be very slow some times because another round trip […]

JSF 2 Conditional Navigation Example

JSF-Thumbnail

As of JSF 2.0, you can supply an if element that activates a navigation case only when the condition is fulfilled. You can configure the condition in the faces configuration file itself to redirect to different views depends on the various conditions. This tutorial highlights the benefits of using the conditional navigation with simple example. Also […]

JSF 2 Navigation using From Action Example

JSF-Thumbnail

You’ve already seen the navigation using  Dynamic Navigation – Action Outcome, but as you’ve noted the using of navigation-case element within a faces-config.xml the from-outcome is provided. The navigation-case element is more complex that we previously discussed, In addition to the from-outcome element, there is also from-action element. That flexibility can be useful if you have two […]