I am using JSF-Spring integration, I am calling a Spring-managed request scoped bean method from the JSP using JSF <h:commandButton>. One thing I can’t understand is that the constructor of the Spring bean is called twice. Why does this happen?
Here is the Spring managed bean:
@org.springframework.stereotype.Component
@org.springframework.context.annotation.Scope("request")
public class MyAction implements java.io.Serializable {
public MyAction(){
System.out.println("inside request scoped bean");
}
Here is the JSF view:
<h:commandButton value="add" action="#{MyAction.add}" />
I got the answer, the constructor was being called twice because of cglib proxy mechanism of Spring.