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 8381717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:45:19+00:00 2026-06-09T16:45:19+00:00

I have a ManagedBean say clsA, inside this clsA has a BOC object that

  • 0

I have a ManagedBean say clsA, inside this clsA has a BOC object that will fill with DI. If I want to invoke the BOC during clsA construction, I will do it in clsA constructor. The code will look like this:

@ManagedBean(name="clsA") 
public class ClsA {

    private BOC boc;

    public clsA(BOC theBoc) {
       theBoc.doFuncA();
    }

    public String doFuncD() { return ""; }       
 }

And the Spring configuration will have this:

<bean id="theBoc" class="com.foo.BOC"/>

<bean id="clsA" class="com.foo.clsA">
   <constructor-arg value="theBoc"/>
</bean>

Now I found a problem that if I have the clsA bean declare inside Spring configuration, my JSF bean, clsA, which is also same name with the one declare inside Spring configuration, will not work. Meaning that if I invoke the doFuncD() from JSF, it is not get call. If I remove the clsA Spring declaration, the JSF bean clsA is working fine.

Is there a better way to invoke BOC from managedBean ClsA constructor?

  • 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-06-09T16:45:21+00:00Added an answer on June 9, 2026 at 4:45 pm

    My work around on this question is:

    1. I’ll remove the constructor code. No more Constructor level dependency injection.
    2. Move the theBoc.doFuncA(); from constructor to setter of ClsA.
    3. Remove the Spring bean, clsA, declaration from Spring configuration file.

    Here is the revised code:

    @ManagedBean(name="clsA") 
    public class ClsA {
    
      private BOC boc;
    
      public clsA(BOC theBoc) {
      }
    
      public String doFuncD() { return ""; }
    
      public void setBoc(BOC boc) {
        this.boc = boc;
        theBoc.doFuncA();
      }
    }
    

    But how do I ensure the setter will only get invoke once only?

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

Sidebar

Related Questions

I have a ParentBean class which has the @ManagedBean annotation. If I subclass this
I have a JSF ManagedBean which has a property that should be set by
have written this little class, which generates a UUID every time an object of
I have a @ViewScope ManagedBean and a @PostConstruct initialisation method. This method is called
I have a custom converter which is this : @ManagedBean @RequestScoped public class MeasureConverter
Let's say I have this action in a JSF Managed Bean: public String doSomething()
Currently I have only one controller AppController ( SessionScope - ManagedBean ) that handles
I have a project with Spring, JSF and Hibernate. This project has been developed
I have a java application build upon Spring 3. This project has another jar
I have this bean: @ManagedBean(name=langListing) @ViewScoped public class LangListing implements Serializable { private List<SelectItem>

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.