-
@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 notProjectStage.Production
, verify that the currentUIViewRoot
does not have itstransient
property set totrue
. If so, add aFacesMessage
for the currentviewId
to theFacesContext
stating@ViewScoped
beans cannot work if the view is marked as transient. Also log aLevel.WARNING
message to the log. IfProjectStage
isProjectStage.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
orPreDestroy
are called when the scope begins and ends, respectively. Two circumstances can cause the scope to end.FacesContext.setViewRoot()
is called with the newUIViewRoot
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 onFacesContext
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 theExternalContext
returned from thatFacesContext
, all of the methods documented as "valid to call this method during application startup or shutdown" are valid to call. In addition, the methodExternalContext.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
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/faces/bean/ViewScoped.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.