【发布时间】:2015-05-21 08:07:43
【问题描述】:
单击确定按钮时,我的“okCancel”类型对话框不会触发服务器上的任何事件。
取消按钮工作正常,只是隐藏了弹出窗口。
我正在使用 Oracle ADF Faces 12.1.3 和 JBoss seam 2.3 来注入 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 在会话范围内。
如果我在 exportImportServer 支持 bean importFromServer 方法内的第一个代码行中切换断点,它不会在里面停止。不会调用此方法。除了提交主表单之外,似乎什么都没有发生(即使我没有错误)。
在调试模式下单击确定按钮后,我可以在 PhaseListener beforePhase(PhaseEvent phaseEvent) 方法内停止。但是我真的不知道是否应该在PhaseListener beforePhase(PhaseEvent phaseEvent)方法之后调用backing bean方法。
我正在寻找有关如何调试它的任何提示?
单击对话框上的 Ok 按钮时是否调用了任何 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 中定义的弹出窗口一起工作的任何提示?
【问题讨论】:
-
点击取消时是否命中了你的方法?
-
对话监听器不应该是
dialogListener="#{ExportImportServerBean.importFromServer}">可能是拼写错误。如果您按“ctrl”并单击jsff页面中的方法名称,您可以测试要调用的方法是否正确。导航是否将您带到方法?用你的 bean 写的? -
是的,如果我在我的 xhtml 页面中按住 ctrl 并单击它,它确实会将我带到我的 bean 中的方法。有没有办法调试呢?例如,我尝试输入
dialogListener="#{bla bla}",它没有显示任何错误,什么也没有。这种行为正常吗?
标签: javascript jsf-2 oracle-adf