我们如何在JSF中加载页面之前调用方法?

时间:2014-01-09 08:12:03

标签: jsf-2

@ManagedBean(name="bean")
@SessionScoped
public class MyBean{

@PostConstruct
public void postConstruct()
{
System.out.println("Inside post Construct");
}

public void beforePageLoad()
{
System.Out.println("Called before pageload for session scoped bean!!!");
}
}


How can we call beforePageLoad method everytime before the page loads.

1 个答案:

答案 0 :(得分:2)

在你的页面内:

 <f:metadata>
    <f:event type="preRenderView" listener="#{bean.listener}"/>
 </f:metadata>