不应该伤害你。如果你在里面做昂贵的东西,你应该把它移到构造器那里,
@PostConstruct
或问题bean的操作方法,或引入延迟加载或阶段嗅探。
// In Constructor..
public Bean() {
constructed = getItSomehow();
}
// ..or @PostConstruct..
@PostConstruct
public void init() {
constructed = getItSomehow();
}
// ..or action method..
public String submit() {
constructed = getItSomehow();
return "outcome";
}
// ..or lazy loading..
public boolean getConstructed() {
if (constructed == null) constructed = getItSomehow();
return constructed;
}
// ..or phase sniffing (this one updates during render response only).
public boolean getConstructed() {
if (FacesContext.getCurrentInstance().getRenderResponse()) constructed = getItSomehow();
return constructed;
}