Jsf 使用<;ui:include/>;表格内
我想确定一个支持bean的范围,使它在每次打开对话框时都是新构造的。 这是一个对话框:Jsf 使用<;ui:include/>;表格内,jsf,primefaces,scope,Jsf,Primefaces,Scope,我想确定一个支持bean的范围,使它在每次打开对话框时都是新构造的。 这是一个对话框: <h:form id="myForm"> <p:dialog header="Title" id="someDialog" widgetVar="someDialog" modal="true" resizable="
<h:form id="myForm">
<p:dialog header="Title" id="someDialog" widgetVar="someDialog" modal="true"
resizable="false" closable="true">
<ui:include src="/WEB-INF/includes/myInclude.xhtml"/>
</p:dialog>
</h:form>
当我第一次单击打开someDialog
的按钮并单击test
时,我会得到以下输出:
post construct
test
对话框按预期隐藏,但不会调用preDestroy,因为它的视图范围是有限的,并且视图不会更改。我看了一下示波器,但似乎没有一个符合我的需要。当对话框被隐藏时,如何实现Bean被销毁?然后在对话框重新打开时再次构造?是什么让您认为包含有自己的视图范围?在你看来,它只是一个组件。我没想到它会工作。我知道我可能还需要别的东西。你可能在找
@Component
@Scope("view")
public class MyController {
private static final Logger LOGGER = LoggerFactory.getLogger(MyController .class);
@PostConstruct
private void postConstruct(){
LOGGER.info("post construct");
}
@PreDestroy
private void preDestroy(){
LOGGER.info("pre destroy");
}
public void test(){
LOGGER.info("test");
PrimeFaces.current().executeScript("PF('someDialog').hide()");
}
}
post construct
test