Results 1 to 4 of 4

Thread: Spring + JSF + PostConstructs

  1. #1
    Join Date
    Oct 2008
    Posts
    20

    Default Spring + JSF + PostConstructs

    Hello, I have successfully integrated Spring + JSF together using Spring's DelegatingVariableResolver. However, I am having an issue when injecting a Spring bean into my JSF managed bean.

    I would like to call a method on my Spring bean during the construction of my managed bean. However, Spring is not injecting this until after the construction of the managed bean.

    Since I am not yet using JSF 1.2, I don't have the PostConstruct annotation at my disposal for my managed bean. Is there another, intuitive, non-hacky way to ensure this method on my Spring bean is called after the construction of my JSF managed bean?

  2. #2
    Join Date
    Oct 2008
    Posts
    2

    Default

    you can do a validation when the var is null.

  3. #3
    Join Date
    Oct 2008
    Posts
    2

    Default

    I'm too new to post a link, so do a search for "constructor-arg"

    Basically create a constructor on your bean, which offers the property you wish to set. Then use constructor-arg to set the property in the spring definition.

  4. #4
    Join Date
    Oct 2008
    Posts
    20

    Default

    Yeah, basically what I did was move the maintenance of all beans to Spring. I was trying to integrate so that JSF managed my managed-beans and Spring managed my service and data access layer. However, I am not a fan of JSF's less-than-robust IoC container, so I moved everything to applicationContext.

    Once I did that, I defined an init-method attribute for the managed bean and all is well now. This method is called after Spring instantiates my managed-bean.

    Thanks for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •