Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 391573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:04:29+00:00 2026-05-12T16:04:29+00:00

Am I right in thinking that this may not be the best idea: private

  • 0

Am I right in thinking that this may not be the best idea:

private static Application app = FacesContext.getCurrentInstance()
        .getApplication();

… or any other call to FacesContext.getCurrentInstance() when you can’t be sure that the current thread of execution is due to a servlet request?

The way I understand it, FacesContext.getCurrentInstance() works by assigning the current faces context to the thread (e.g. ThreadLocal variable). The above will probably usually work in a class like a JSF backing bean or JSF component class, since the thread of execution that happens to load the class and instantiates the class members (static variables) is usually going to be a FacesServlet request. But I still don’t think it’s a good idea to count on it.

Agree or disagree? Ideas? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:04:29+00:00Added an answer on May 12, 2026 at 4:04 pm

    Using FacesContext.getCurrentInstance() during initialization may or may not be a good idea depending upon the context.

    I can’t imagine a scenario where assigning it to a static var would ever be a good idea, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may not be the right place for this question, but the reason I
Am I right in thinking that until I am able to afford dedicated servers
Am I right in thinking that the HTML5 peertopeerconnection() for enabling peer to peer
I'm not thinking too clearly right now and possibly overlooking something simple. I've been
I don't know if I'm thinking of this the right way, and perhaps somebody
I am thinking about some issues which may match the term software integration best.
I am using ColdFusion 9.0.1. Let me start by stating that I may not
I realize the music application may or may not be the same depending on
have span that may or may not have text content. is there a way
According to this answer : HTML 4.01 specifies that <a> elements may only contain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.