Spring 使用独立的JSF页面调用(而不是)惰性加载的rich:popupPanel的最佳方法
我试图插入一个弹出窗口,当单击Spring 使用独立的JSF页面调用(而不是)惰性加载的rich:popupPanel的最佳方法,spring,jsf-2,popup,richfaces,Spring,Jsf 2,Popup,Richfaces,我试图插入一个弹出窗口,当单击h:commandButton时,该弹出窗口必须延迟加载。我通过ui:include插入其内容。但是,preRenderView方法没有被激发,并且pouppagemodel模型属性没有被初始化,因此我在尝试调用pouppagecontroller中的业务逻辑方法时得到了一个NullPointerException 我们的想法是为涉及的两个页面提供单独的模型/控制器bean,但我不确定这是正确的方法,因此我想知道其他方法或实现我的方法的正确方法 提前谢谢 调用页面:
h:commandButton
时,该弹出窗口必须延迟加载。我通过ui:include
插入其内容。但是,preRenderView
方法没有被激发,并且pouppagemodel模型
属性没有被初始化,因此我在尝试调用pouppagecontroller
中的业务逻辑方法时得到了一个NullPointerException
我们的想法是为涉及的两个页面提供单独的模型/控制器bean,但我不确定这是正确的方法,因此我想知道其他方法或实现我的方法的正确方法
提前谢谢
调用页面:
<h:commandButton
value="#{msg['jsf.thisScreen.someText']}">
<f:param name="theParameter" value="#{InvokingScreenModel.theParameter}" />
<rich:componentControl target="myPopup" operation="show" />
</h:commandButton>
<rich:popupPanel id="myPopup" modal="true" resizeable="false" autosized="true"
onmaskclick="#{rich:component('myPopup')}.hide()">
<f:facet name="header">
<h:outputText value="#{msg['jsf.anotherScreen.someText']}" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#" onclick="#{rich:component('myPopup')}.hide(); return false;"></h:outputLink>
</f:facet>
<ui:include src="popupPage.xhtml" />
</rich:popupPanel>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:c="http://java.sun.com/jsf/core">
<f:metadata>
<f:viewParam name="theParameter"
value="#{PopupPageModel.theParameter}" />
<f:event type="preRenderView"
listener="#{PopupPageController.initialize}" />
</f:metadata>
<h:form id="someForm">
//Some things here
</h:form>
</ui:composition>
我已经为此苦苦挣扎了好几天,我一直无法找到一个延迟加载弹出窗口的解决方案,所以我发布了一个解决方案,我设法做到了这一点,不包括这个功能,只是为了以防万一,它是有用的人 调用页面提取
<h:form>
<a4j:outputPanel id="stuffDetails">
//Some ajax-rendered tabs and accordions above the button
.....
.....
<a4j:commandButton
value="Open Popup"
actionListener="#{PopupController.someInitializationListenerMethod}"
oncomplete="#{rich:component('thePopup')}.show();"
render="formPopup">
</a4j:commandButton>
</a4j:outputPanel>
</h:form>
<rich:popupPanel id="thePopup" modal="true"
resizeable="false" autosized="true"
onmaskclick="#{rich:component('thePopup')}.hide();">
<f:facet name="header">
<h:outputText value="Some header here" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#"
onclick="#{rich:component('thePopup')}.hide(); return false;">
</h:outputLink>
</f:facet>
<h:form id="formPopup">
<ui:include src="popup.xhtml" />
</h:form>
</rich:popupPanel>
由BalusC和
欢迎提供任何建议。请参阅f:metadata
,其中指出:“此标记必须位于给定viewId的顶级XHTML文件中,或位于模板客户端中,但不在模板中。”这解释了事件不触发的原因。至于你的架构:这里需要请一位spring专家,不知道在正常的JSF/CDI之外如何工作。谢谢你的回答,@mabi。我怀疑我使用的f:metadata
标记不正确。我想我也应该改变架构,但我不确定。让我们看看是否有其他人回答:)
<h:form>
<a4j:outputPanel id="stuffDetails">
//Some ajax-rendered tabs and accordions above the button
.....
.....
<a4j:commandButton
value="Open Popup"
actionListener="#{PopupController.someInitializationListenerMethod}"
oncomplete="#{rich:component('thePopup')}.show();"
render="formPopup">
</a4j:commandButton>
</a4j:outputPanel>
</h:form>
<rich:popupPanel id="thePopup" modal="true"
resizeable="false" autosized="true"
onmaskclick="#{rich:component('thePopup')}.hide();">
<f:facet name="header">
<h:outputText value="Some header here" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#"
onclick="#{rich:component('thePopup')}.hide(); return false;">
</h:outputLink>
</f:facet>
<h:form id="formPopup">
<ui:include src="popup.xhtml" />
</h:form>
</rich:popupPanel>
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
<html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:c="http://java.sun.com/jsf/core">
//Some controls shown inside the popup
......
......
<a4j:commandButton value="Process data and close popup"
actionListener="#{PopupController.someProcessingMethod}"
render=":stuffDetails :formPopup"
oncomplete="#{rich:component('thePopup')}.hide();" />
<h:commandButton value="Cancel"
onclick="#{rich:component('thePopup')}.hide(); return false;" />
</ui:composition>
</html>