Exam 1z0-900 All QuestionsBrowse all questions from this exam
Question 56

You are building the User Preferences page of an application. A user can change values, such as his or her name, password, address, company, and so on.

These values are sent to a CDI backing bean via AJAX when the user tabs out of each field. However, the values must be retained in the CDI bean and stored in the database only when the user clicks the Save button.

Which two scopes will allow your CDI bean to retain its state while the user is interacting with the User Preferences page? (Choose two.)

    Correct Answer: B, C

    To ensure that the CDI bean retains its state while the user is interacting with the User Preferences page and only persists data upon clicking the Save button, we need to use scopes that allow maintaining state throughout the user's interaction with the page. The View scope is appropriate because it retains the state of the bean while the user is interacting with a specific view (or page) in a web application. The Session scope is suitable because it retains the bean state throughout the user's session, allowing data to be persisted across multiple interactions within the same session but discarded after the session ends. Using Dependent, Request, or Application would not meet these criteria as they either do not maintain state effectively across multiple requests or are too global/isolated in scope.

Discussion
devmsalehOptions: BC

Answer should be : B and C

emtchanOptions: BC

The answer should be B and C (View and Session).

orjavaOptions: BC

Answer B, C. Application Scope and Dependent Scope surely not. Request Scope only retains data by the duration of a request. View and Session scope is correct.

LeoAliothOptions: CE

according to this https://docs.oracle.com/javaee/7/tutorial/cdi-basic008.htm, C and E are correct