单击“确定”按钮时,“okCancel”类型的对话框不会触发服务器上的任何事件。
取消按钮工作正常,只是隐藏了弹出窗口。
我使用 Oracle ADF Faces 12.1.3 和 JBoss seam 2.3 来注入(inject) Bean。
这是弹出窗口和对话框代码:
<af:form id="mainForm">
<af:panelStretchLayout id="psl1">
<!-- page layout -->
</af:panelStretchLayout>
<af:popup id="myPopup"
binding="#{bkBean.myPopup}"
contentDelivery="lazyUncached">
<af:dialog id="myDialog" closeIconVisible="true"
modal="true" okVisible="true" cancelVisible="true"
title="Import from server to #{bkBean.file.name}"
type="okCancel"
dialogListener="#{bkBean.doSomething}">
<af:panelFormLayout id="pfl1">
<!-- Several input text here -->
</af:panelFormLayout>
</af:dialog>
</af:popup>
</af:form>
这是dialogListener 的代码。我在 if 语句处设置了一个调试点:
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
@Name("exportImportServer")
@Scope(ScopeType.SESSION)
public class ExportImportServerBean implements Cleanable {
public void importFromServer(DialogEvent event) {
if (event.getOutcome() == DialogEvent.Outcome.ok) {
}
}
}
exportImportServer 支持 bean 位于 session 范围内。
如果我在exportImportServer 支持bean importFromServer 方法内的第一个代码行中切换断点,它不会在内部停止。该方法不会被调用。除了提交主表单之外,似乎没有任何反应(即使我没有错误)。
在 Debug模式下,单击“确定”按钮后,我可以在 PhaseListener beforePhase(PhaseEvent PhaseEvent)
方法内停止。但我真的不知道是否应该在 PhaseListener beforePhase(PhaseEvent PhaseEvent)
方法之后调用支持 bean 方法。
我正在寻找有关如何调试它的任何提示?
单击对话框上的“确定”按钮时是否调用任何 JavaScript?
更新:问题似乎来自这样一个事实:弹出窗口是从页面的某个区域调用并在另一个页面(包含该区域的主页面)中定义的,如下面的代码所示:
main.xthml 内部:
<af:document>
<af:form id="mainForm">
<af:panelStretchLayout id="psl1" topHeight="auto" bottomHeight="0">
<f:facet name="center">
<af:region id="myRegion" showHeader="never"
value="#{main.regionModel}" />
</f:facet>
</af:panelStretchLayout>
</af:form>
<af:popup id="myPopup"
binding="#{bkBean.myPopup}"
contentDelivery="lazyUncached">
<af:dialog id="myDialog" closeIconVisible="true"
modal="true" okVisible="true" cancelVisible="true"
title="Import from server to #{bkBean.file.name}"
type="okCancel"
dialogListener="#{bkBean.doSomething}">
<af:panelFormLayout id="pfl1">
<!-- Several input text here -->
</af:panelFormLayout>
</af:dialog>
</af:popup>
</af:document>
myRegion.xhtml 内部:
<?xml version='1.0' encoding='UTF-8'?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:trh="http://myfaces.apache.org/trinidad/html"
xmlns:tr="http://myfaces.apache.org/trinidad"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:tree ...>
</af:tree>
<!-- Contextual Menu -->
<af:popup id="pp1" contentDelivery="lazyUncached">
<af:menu>
<af:commandMenuItem text="Do something" immediate="true"
rendered="#{bkBean2.isRendered}" icon="icon.png" actionListener="#{bkBean2.showMyPopup}" />
</af:menu>
</af:popup>
</ui:composition>
如果我在 myRegion.xhtml 中定义弹出窗口,它会起作用,但如果我在 main.xhtml 中定义弹出窗口,则不起作用。
感谢您提供有关如何使其与 main.xhtml 中定义的弹出窗口一起工作的任何提示?
最佳答案
您有两个选择:
尝试在 adfc-config.xml 中映射您的 bean,而不是使用注释。
保留注释并确保在 ADF 应用程序中使用启用 CDI,如下所示:
http://www.jobinesh.com/2014/08/enabling-cdi-in-adf-applications.html
值得一提的是,CDI(基于注释的 Bean)并没有经常与 ADF 一起使用 - 至少关于人们遵循 CDI 方法的信息很少 - 因此您可能正在未知的领域行走。
关于javascript - ADF Faces 对话框 -dialogListener 未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30368000/