Search code examples
jsfjsf-2annotations

ResourceDependency annotation doesn't work in a UIComponent and generates "RES_NOT_FOUND" error in the src


I'm developing a UIComponent that uses a javascript file with @ResourceDependency annotation, but instead of generating a link to the file, it just prints "RES_NOT_FOUND" in the src atribute, like this:

<script type="text/javascript" src="RES_NOT_FOUND"></script>

Follow the java code:

@ResourceDependency(name="file.js")
public class ComponenteTest extends UIComponentBase {

Does anybody know what's happening?


Solution

  • This particular annotation configuration expects the file to be located in /resources/file.js of the public webcontent.

    It's exactly the same as if you would be using the following in the view:

    <h:outputScript name="file.js" />
    

    If the file is located elsewhere, or when the name (or library) is actually wrong, then it will generate exactly this RES_NOT_FOUND URL.