Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hidden field on the page  RSS feed

 
MaheshS Kumbhar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"If state is saved on the client, the state of the entire view is rendered to a hidden field on the page".
I didn't get the meaning of above statement.
Can anyone please help.
 
Tim Holloway
Bartender
Posts: 18704
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The FacesContext only exists while a request/response is actually processing. So you need somewhere to hold the information that's used to (re)build the View in the mean time - that is to say, the view state.

You have 2 options:

1. Store the state on the server. This is more secure and has less network overhead, but it requires resources proportional to the number of users of the webapp.

2. Store the state on the client. This is less secure (since the client could be hacked, infected, or just evil-minded). And it requires that the state be transferred to/from the server with each request. But it doesn't require increasing server resources (other than processing resources) as the number of users increases.

If you opt for client-side view state storage, a mechanism is needed for ensuring that the state information is transmitted to the server, and in order to assure maximum portability for HTTP/HTML, the easiest way to do that is to keep the state data in an HTML form field so that it makes the trip along with the rest of the form data.

Obviously, you don't want all this bulky and cryptic information cluttering up the user's screen, so an invisible field is used.
 
MaheshS Kumbhar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim for giving such a detailed answer.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!