Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用extendedrenderkitservice添加脚本_Java_Javascript_Oracle Adf_Adobe Analytics - Fatal编程技术网

Java 使用extendedrenderkitservice添加脚本

Java 使用extendedrenderkitservice添加脚本,java,javascript,oracle-adf,adobe-analytics,Java,Javascript,Oracle Adf,Adobe Analytics,我在添加脚本时遇到问题。请在下面找到我的代码 FacesContext facesContext = FacesContext.getCurrentInstance(); ExtendedRenderKitService extendRenderKitService = Service. getRenderKitService(facesContext, ExtendedRenderKitService.class); try { Stri

我在添加脚本时遇到问题。请在下面找到我的代码

    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExtendedRenderKitService extendRenderKitService = Service.
        getRenderKitService(facesContext, ExtendedRenderKitService.class);
    try {
        String methodCall = "afterPPRProcessing('" + journeyId + "',new Array (" + dynamicParams + "))";
        System.out.println( "methodCall::" + methodCall);
        extendRenderKitService.addScript(facesContext, methodCall);
    } catch (Exception ex) {
        System.out.println("exception while PPR processing ", ex);
    }
我正在使用

  • javax.faces.context.FacesContext
  • org.apache.myfaces.trinidad.render.ExtendedRenderKitService
  • org.apache.myfaces.trinidad.util.Service 实际上,我想基于事件生成Omniture,比如(按钮点击等) 后处理是javascript中的一种方法。这段代码可以完美地运行,并将“methodCall”打印为

    我在执行页面时在“AfterPProcessing”方法中设置了断点,但它不会在断点处停止

    请帮助我了解未生成标记的原因。在编写代码时是否有任何错误


    提前感谢

    此代码可能不起作用有几个原因:

  • 未定义处理后的Javascript方法
  • 处理后的Javascript方法没有相同数量的参数

  • 通过启动chrome developer控制台确保javascript函数存在,并在浏览器中尝试此语法以查看是否一切正常。

    为了使用ExtendedRenderKitService调用任何javascript函数,函数调用必须在PPR响应中在分析过程中,我发现PPR响应中缺少omniture调用“afterPPRProcessing”,原因是在使用上述代码从Bean类添加脚本后,有一个代码刷新整个页面。下面是代码

        FacesContext context = FacesContext.getCurrentInstance();
        String viewId = context.getViewRoot().getViewId();
        ViewHandler handler = context.getApplication().getViewHandler();
        UIViewRoot root = handler.createView(context, viewId);
        root.setViewId(viewId);
        context.setViewRoot(root);
    
    此代码段正在执行页面刷新,而此方法用于捕获PPR事件(开/关)。因此,脚本不会添加到ExtendedRenderKitService中的facesContext

    在注释完这段代码后,PPR调用运行良好,我能够生成矩阵

    感谢人们的帮助


    希望这对其他人有所帮助

    我已经检查并确认后处理方法是在javascript中定义的,并且具有相同的参数。我尝试在控制台中点击该方法并生成标记。但是当我尝试从java代码点击时,不会生成标记。如果此函数尝试操作HTML DOM,则要确保您使用的是ADF Javascript API,没有它,您将无法成功完成。我使用的是ADF Javascript API。不生成的原因可能是什么。下面提前感谢的帮助是代码-->函数afterPPRProcessing(jid,params){var obj=evalJSString(jid);//调用pre方法调用evalJSString(obj.premc);//通过与动态参数var omnitag=mergeDynamicParams(obj.params,params)合并来创建标记脚本;//设置参数evalJSString(omnitag);//Omniture调用var s_code=s.t();if(s_code)document.write(s_code);//调用post方法调用evalJSString(obj.postc);}感谢您的帮助。我已经找到了根本原因并回答了我的问题。ThankssIs有没有办法在randering之前删除添加的脚本?我的意思是在添加脚本之后,如果需要在呈现已添加的页面之前将其删除或替换。
        FacesContext context = FacesContext.getCurrentInstance();
        String viewId = context.getViewRoot().getViewId();
        ViewHandler handler = context.getApplication().getViewHandler();
        UIViewRoot root = handler.createView(context, viewId);
        root.setViewId(viewId);
        context.setViewRoot(root);