0
votes

Hy,

I am a newbie in JSF and I have read about how JSF stores UIComponents or commonly said screens in session. Some questions:

  1. when you request a jsf file for example, JSF first analyzes it and creates like a screen representation in memory with his renderers, validators, converters because JSF will process requests from this view quicker the next time because it has already created this UIComponent structure with his validator, converters ...., right?

  2. With JSF with java code you can modify the screen presented to the user like java swing, right?

  3. These screens are saved in session, right?

  4. What I dont know is if JSF can repopulate a form when a user for example press the back button in a browser with the values he sent, is this possible?

  5. The values of form fields are saved in model beans but these values are stored in somewhere else?, in the UIComponent structure maybe?

  6. What would happen in the case a user press the back button of the browser and the values he sent in the form were saved in beans with request scope, it wouldnt be able to repopulate the form unless it stores the values of the form in the UIComponent structure, right?

Thanks

2

2 Answers

0
votes
  1. There is probably some caching but it isn't inherent in the design or the specification as far as I know.
  2. You can modify the presentation, yes; like javax,swing, no.
  3. No.
  4. If the browser resends the POST the same things will happens as happened the first time. The form field values are resent, JSF processes them, same as before,
  5. The values of the form fields are in the form fields and in any backing bean properties that are specified as values via EL.
  6. See (4). Same question, same answer.
0
votes

For your subject question: by default, yes. Unless the component is marked as transient

For you questions:

1.) It is not (just) for the quickness. The restoration of the view is needed, because that holds the information about the needed converters, validators and the connections between the UI and your beans. Namely the EL expressions. If you don't have an active view and you trigger a post-back request (with a ViewState) you will get a ViewExpiredException. If you trigger a request without a ViewState, a new view will be generated.

2.) Basically yes. It is like swing in terms of you can pragmatically add new components to the tree.

3.) By default, yes. But you can write your own StateManager and you can store and retrive the view wherever you want.

4.) The back button (by default) goes back in the browser's history and shows the page from cache. If your view is not transient, than it can be stored in the session unless it is too old (see the corresponding context param). If you trigger a request from the an old view and that view is still in the session, it will be handled properly. Otherwise it will throw a ViewExpiredException in the APPLY_REQUEST phase.

5.) The values are stored in you beans. The component only holds the EL expression pointing your bean's attribute

6.) See 4.) and 5.)