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);
}
我正在使用
提前感谢此代码可能不起作用有几个原因:
通过启动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);