繁体   English   中英

ADF Faces对话框-dialogListener不触发

[英]ADF Faces dialog - dialogListener not triggering

单击“确定”按钮时,我的类型为“ 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方法。

我正在寻找有关如何调试的任何提示?
单击对话框上的“确定”按钮时,有没有调用任何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中定义的弹出窗口一起使用的任何提示?

您有两种选择:

  1. 尝试在adfc-config.xml中映射bean,而不要使用注释。

  2. 保留注释,并确保您在ADF应用程序中使用启用CDI,如下所示:

http://www.jobinesh.com/2014/08/enabling-cdi-in-adf-applications.html

值得一提的是,ADF并不经常使用CDI(基于注释的Bean)-至少很少有人遵循CDI方法的信息-因此您可能会在未知的领域行走。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM