-
Bug
-
Resolution: Obsolete
-
Critical
-
None
-
None
Since Mojarra 2.1.18 upgrade, the JSF doesn't render required @ResourceDependency of custom renderers on postback, if the component is bound.
Having an renderer:
@ResourceDependencies({ @ResourceDependency(library = "my", name = "mylib.js") }) public class MyOutputTextRenderer extends Renderer { @Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { context.getResponseWriter().startElement("button", null); context.getResponseWriter().writeAttribute("onclick", "javascript:myHello();", null); context.getResponseWriter().writeText("Hello, world", null); context.getResponseWriter().endElement("button"); } }
And
<h:form> <my:hello binding="#{counter.hello}"/> <h:commandButton value="Send" action="#{counter.add}" /> </h:form>
The rendered output contains the required mylib.js only in the first request, but no script element with mylib.js is rendered in the header on the page after clicking the "Send" button, thus breaking the custom component.
Note that this happens only if the the component is using the "binding" attribute.
@ManagedBean(name = "counter") @ViewScoped public class Counter implements Serializable { private int counter = 0; private UIOutput hello; public void setHello(UIOutput hello) { this.hello = hello; } public UIOutput getHello() { return this.hello; } public void add() { ++counter; } public int getCounter() { return counter; } }