• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I read a session variable inside a Managed Bean?

 
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My ManagedBean that does a database acccess has a PreparedStatement that will do a query based on the userID that's in the session scope.

In the managed bean, I have something like this:

"SELECT * FROM USERS WHERE USR_ID = ?", but the usr_ID is actually in a session variable.

I can't figure out how to get at the session (scope) variable from within the ManagedBean.

How is this done?

Thanks very much to all replies!!!

-- Mike
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Also, you can reach any session object using the Value Binding. For example:



--
Sergey : http://jsfTutorials.net
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WOW!

Where did you learn that? <s>

That is not in my "Core JSF" book.

Clearly I need another reference book to compliment the Core book.

Thanks very very very much!!!

-- Mike
 
Sergey Smirnov
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still recommend "Core JSF" :-)
See in the chapter 2:
* "Note" under the Table 2-2
* Table 2-4 (Predefined Objects)

--
Sergey : http://jsfTutorials.net
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're right, it *is* in Core JSF.... now that I know the answer, I see it. <s>

Perhaps this tecnhique would have been a good addition to the "how do I..." section in the later chapter: "How do I read a session variable in a JSF page / Managed Bean?"

Thanks very much again!!!

-- Mike
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually:

FAQ 1
and
FAQ 2

Are FAQ-entries in that direction...

Therefor we have a new ressource to check... and (oh no) another forum to watch...
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Alexnander!

-- M
 
It is difficult to free fools from the chains they revere - Voltaire. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic