附加到渲染器时,@ ResourceDependency不起作用

时间:2018-12-12 20:48:03

标签: spring jsf java-ee

我定义了一个自定义组件,并且可以在2个渲染器之间进行切换。其中一个渲染器使用客户端JavaScript,并且需要将该lib发送到:head元素。

@ResourceDepedency附加到自定义组件public class SomeCustComp extends UIInput时,它可以正常工作。但是何时:

@ResourceDependency(name="SomeLib.js", target="head")
@FacesRenderer(componentFamily="custom-renderers", rendererType="variant2")
public class AnotherRendererVariant extends Renderer {...

结果页面不会在<head>元素中包含脚本。

我尝试通过以下方式在渲染器的encodeEnd()中以编程方式添加元素:

UIComponent script = (UIComponent)ctx.getApplication().createComponent("javax.faces.Output");
script.setRendererType("javax.faces.resource.Script");
script.getAttributes().put("name", "SomeLib.js");
script.getAttributes().put("target", "head");
context.getViewRoot().addComponentResource(context,  script, "head");

但是那也不行。

文档明确声明,实现必须支持@ResourceDepedency的自定义组件和自定义渲染器。我想我不是-tomcat8,spring5。

有人遇到这样的问题吗?

0 个答案:

没有答案