Clone wiki

Oracle JSF Expert 1Z0-896 / JSF Scopes

#JSF Scopes

javax.faces.bean Annotations

The following scope related annotations exist in this package

  • @RequestScoped this is the default scope if one isn't specified
  • @ApplicationScoped the scope of these is the same as the application
  • @SessionScoped
  • @ViewScoped lives as long as a "view" stays alive, useful for pages that process AJAX requests.
  • @NoneScoped a none scoped bean will be initialised every time it is access via an EL expression, an exception to this is when a none scoped bean is for example injected into a @SessionScoped bean using @ManagedProperty, in that case it will live as long as the session.
  • @CustomScoped


import javax.faces.bean.ManagedBean
import javax.faces.bean.RequestScoped

public class UserBean {
    private String name;

    public String getName() {
        return name;

    public void setName(String name) { = name;
<html xmlns=""
    <title>User Bean</title>
        <h:panelGrid columns="2">
            <h:inputText id="name" value="#{}" required="true">
                <f:ajax event="keyup" render="error" />
            <h:message for="name" id="error" style="color: red" />

CDI Scopes

javax.enterprise.context annotations

  • @RequestScoped
  • @SessionScoped
  • @ApplicationScoped
  • @ConversationScoped