javax.faces.bean

Annotation Type ViewScoped


  • @Retention(value=RUNTIME)
     @Target(value=TYPE)
     @Inherited
    public @interface ViewScoped

    When this annotation, along with ManagedBean is found on a class, the runtime must act as if a <managed-bean-scope>view<managed-bean-scope> element was declared for the corresponding managed bean.

    If ProjectStage is not ProjectStage.Production, verify that the current UIViewRoot does not have its transient property set to true. If so, add a FacesMessage for the current viewId to the FacesContext stating @ViewScoped beans cannot work if the view is marked as transient. Also log a Level.WARNING message to the log. If ProjectStage is ProjectStage.Production, do not do this verification.

    The bean must be stored in the map returned from javax.faces.component.UIViewRoot.getViewMap(boolean).

    The runtime must ensure that any methods on the bean annotated with PostConstruct or PreDestroy are called when the scope begins and ends, respectively. Two circumstances can cause the scope to end.

    • FacesContext.setViewRoot() is called with the new UIViewRoot being different than the current one.

    • The session, that happened to be active when the bean was created, expires. If no session existed when the bean was created, then this circumstance does not apply.

    In the session expiration case, the runtime must ensure that FacesContext.getCurrentInstance() returns a valid instance if it is called during the processing of the @PreDestroy annotated method. The set of methods on FacesContext that are valid to call in this circumstance is identical to those documented as "valid to call this method during application startup or shutdown". On the ExternalContext returned from that FacesContext, all of the methods documented as "valid to call this method during application startup or shutdown" are valid to call. In addition, the method ExternalContext.getSessionMap() is also valid to call.

    The annotations in this package may be deprecated in a future version of this specification because they duplicate functionality provided by other specifications included in JavaEE. When possible, the corresponding annotations from the appropriate Java EE specification should be used in preference to these annotations. In this case, the corresponding annotation is javax.faces.view.ViewScoped. The functionality of this corresponding annotation is identical to this one, but it is implemented as a CDI custom scope.

    Since:
    2.0

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Version en cache

21/08/2025 19:10:05 Cette version de la page est en cache (à la date du 21/08/2025 19:10:05) afin d'accélérer le traitement.
Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.

Document créé le 11/06/2005, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/faces/bean/ViewScoped.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com, ViewScoped (Java(TM) EE 7 Specification APIs)

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.