The simplest route I found was the following:
Copy your YourScript.js to META-INF/adf/jsLibs in your custom component jar.
Then in your renderer add the following code. This will cause your script
to be added only once the first time your component is used in a page.
@Override
protected void findTypeConstants(Type type)
{
super.findTypeConstants(type);
scriptLib = new LibraryScriptlet("YourScript", null);
}
@Override
protected void encodeAll(FacesContext context, RenderingContext arc,
UIComponent component, FacesBean bean) throws IOException
{
// output the popup javascript library
scriptLib.outputScriptlet(context, arc);
...do your encoding here
}
private Scriptlet scriptLib;
Regards,
Danny
On 5/23/07, William Hoover <[EMAIL PROTECTED]> wrote:
I was wondering if anyone knows how to add a* js* resource in Trinidad? I
have a custom component that needs to render a script. I noticed that there
is a* org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils*class
that has the
* writeLibImport(FacesContext context, RenderingContext arc, Object
libURL)* and* addLib(FacesContext context, RenderingContext arc, Object
libKey)* methods. Is this the correct approach? Is there a better way to
add the script without referring to a implicit URL? Can the*
org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.jsLibs.AliasedScriptlet
* class be used to accomplish this?
--
Chordiant Software Inc.
www.chordiant.com