Top "Postconstruct" questions

@PostConstruct is a Java EE annotation used to select a method that needs to be executed after dependency injection is done to perform any initialization.

When to use f:viewAction / preRenderView versus PostConstruct?

When should one use the f:viewAction or preRenderView event to initialize data for a page versus using the @PostConstruct …

jsf jsf-2 postconstruct prerenderview viewaction
How to test constructor of a class that has a @PostConstruct method using Spring?

If I have a class with a @PostConstruct method, how can I test its constructor and thus its @PostConstruct method …

java spring unit-testing junit postconstruct
Guice call init method after instantinating an object

Is it possible to tell Guice to call some method (i.e. init()) after instantinating an object of given type? …

guice init postconstruct
@PostConstruct method called twice for the same request

I'm using JSF 2.0 with GlassFish 3.0. I have the following Managed Bean: @ManagedBean @RequestScoped public class OverviewController{ private List<Event&…

java jsf jsf-2 postconstruct
Testing spring bean with post construct

I have a bean similar to this: @Service public class A { @Autowired private B b; @PostConstruct public void setup() { b.…

spring junit postconstruct
Why does @PostConstruct callback fire every time even though bean is @ViewScoped? JSF

I am using datatable on page and using binding attribute to bind it to my backing bean. This is my …

jsf facelets view-scope postconstruct
@PostConstruct & Checked exceptions

In the @PostConstruct doc it says about the annotated methods: "The method MUST NOT throw a checked exception." How would …

java jakarta-ee exception-handling postconstruct
org.jboss.weld.exceptions.WeldException: WELD-000049: Unable to invoke private void init()

For some reason, the following code is not working, and I do not understand why. My current, and quite hand-wavy, …

jsf cdi private-methods postconstruct
@ViewScoped calls @PostConstruct on every postback request

This doesn't seem right. I was doing some cleanup of my code and I just noticed this. Every ajax request …

jsf jsf-2 constructor view-scope postconstruct
Unit testing: Call @PostConstruct after defining mocked behaviour

I have two classes: public MyService { @Autowired private MyDao myDao; private List<Items> list; @PostConstruct private void init(){ …

java spring unit-testing mockito postconstruct