【问题标题】:Validation before firing a popup in adf Popup在 adf Popup 中触发弹出窗口之前的验证
【发布时间】:2018-04-23 12:46:06
【问题描述】:

仅当某个数据验证为正时(如果 vo 结果返回多于零行),我想在导航到新页面片段之前触发弹出窗口。如何添加此验证以检查 vo 结果并显示弹出窗口仅当验证结果为真时。单击命令链接时应显示弹出窗口。如果显示弹出窗口,则不进行新导航。如果验证返回错误,我们应该导航到新页面片段而不是显示弹出窗口.

【问题讨论】:

    标签: oracle oracle-adf


    【解决方案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 .....
        }
    
      }
    

    【讨论】:

      猜你喜欢
      • 2018-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多