• Post Reply Bookmark Topic Watch Topic
  • New Topic

get value in javascript from session

 
Irakli Bliadze
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I working in netbeans 7.6 visual Jsf,
I wanted to get value in javascript body onLoad from session and i did it such "got value in hiddenField from session then by timeout got value in javascript from session ".
Is any better way to get value from session in javascript? and if possible how?
 
Sachin Yewale
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Irakli Bliadze,

You can directely access managed Bean value in Javasript.
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sachin Yewale wrote:Hi Irakli Bliadze,

You can directely access managed Bean value in Javasript.


No you can't.

JavaScript runs entirely on the client and the managed beans live entirely on the server.

The only way to access managed bean property values in javascript code is to employ AJAX, and while AJAX is JavaScript, it's hardly "direct access".

You can use EL to get the value of a Managed Bean as of the time that the View is loaded into the client, but that's simply a value expansion and it will neither allow updating the bean value nor will it reflect any changes made to the bean after the View was displayed.
 
Irakli Bliadze
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks both for answer, i now about ajax but doubt some browsers against ajax
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!