在adf Popup中触发弹出窗口之前的验证

时间:2018-04-23 12:46:07

标签: oracle oracle-adf

我希望在导航到新的页面片段之前触发弹出窗口,只有当某个数据验证为正时(如果vo结果返回的行数超过零)。如何添加此验证来检查vo结果并显示弹出窗口只有当验证结果为真时。单击命令链接时应显示弹出窗口。如果弹出窗口显示没有新导航完成。如果验证返回false,我们应该导航到新的页面片段而不是显示弹出窗口

1 个答案:

答案 0 :(得分:1)

使用以下代码以编程方式显示弹出窗口

public static void showPopup(RichPopup pop, boolean visible) {
    try {
        FacesContext context = FacesContext.getCurrentInstance();
        if (context != null && pop != null) {
            String popupId = pop.getClientId(context);
            if (popupId != null) {
                StringBuilder script = new StringBuilder();
                script.append("var popup = AdfPage.PAGE.findComponent('").append(popupId).append("'); ");
                if (visible) {
                    script.append("if (!popup.isPopupVisible()) { ").append("popup.show();}");
                } else {
                    script.append("if (popup.isPopupVisible()) { ").append("popup.hide();}");
                }
                ExtendedRenderKitService erks =
                    Service.getService(context.getRenderKit(),
                                       ExtendedRenderKitService.class);
                erks.addScript(context, script.toString());
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

然后将动作侦听器添加到链接

 public void redirectAcion(ActionEvent actionEvent) {

 ViewObject yourViewObject= ADFUtils.getAm().getYourViewObject();

 long numOfRecords=yourViewObject.getEstimatedRowCount();
      if(numOfRecords==0)
       showPopup(myPopup,true);

    else{
     //redirect code .....
    }

  }