Page On load event in JSF

2019-08-22 04:27发布

问题:

I am trying to assign values to my dropdown during page load. I followed the way which is given in this link.

Invoke JSF managed bean action on page load

As per the link, i have tried using both the annotation and constructor type.

but its an exception for me,

 SEVERE: An exception occurred
 javax.faces.FacesException: java.lang.reflect.InvocationTargetException

 Caused by: java.lang.reflect.InvocationTargetException
 Caused by: javax.el.ELException: Detected cyclic reference to managedBean loginBean
 Caused by: javax.faces.el.EvaluationException: Detected cyclic reference to managedBean loginBean

I have just tried to call a function, in that annotated method or constructor, that is,

     @PostConstruct
public void init()
{
receiveclass r=new receiveclass();
r.retrieve();

} 

i cant able to figure out the problem.

回答1:

Detected cyclic reference to managedBean loginBean

You're injecting two different managed beans in each other as @ManagedProperty. This isn't allowed. It should be an one-way injection. Remove the @ManagedProperty referencing the one bean from the other bean.