JSF Bean & Bean Constructor

0

Posted by Jagadeesh VP | Posted in

Using constructor in bean class will make all the references from faces-config.xml to null.
This throws the exception.

But for some bean constructor in necessary for initialization.

This problem can be avoided by using @PostConstruct annotation.

Eg:

public MyBean(){
someMethod();
}
the above constructor can be replaced by

@PostConstruct
public void myBeanMethod(){
someMethod();
}

The method defined with this annotation will be called immediately after finishing the construction of Bean object.

Note : This annotation won't works in JSF 1.1

Quotes

0

Posted by Jagadeesh VP | Posted in

"All that is valuable in human society depends upon the opportunity for development accorded the individual."

Anyone who doesn't take truth seriously in small matters cannot be trusted in large ones either.

Albert Einstein


"So in the Sun world, the hard stuff is possible, but the easy stuff is hard. In the Microsoft world, the easy stuff is easy, but the hard stuff is impossible."

James Gosling