I need to do this from Java code, I was trying the following, but got stuck:
UIOutput js = new UIOutput();
js.setRendererType("javax.faces.resource.Script");
js.getAttributes().put("library", "js");
js.setValue("alert(123);");
FacesContext context = FacesContext.getCurrentInstance();
context.getViewRoot().addComponentResource(context, js, "body");
I didn't get an error with this in the server log, but also didn't see the alert.
Any idea?
EDIT: I tried the suggested solution, the alleged duplicate, and I didn't get a server error either, but neither did I see any alert..