Using the outputScriplet method I'm getting an HTTP 404 error. I placed the js
in the /META-INF/adf/jsLibs/MyScript.js It looks as though the script is
requested, but the js file contains the html for a 404. Any clue?
-----Original Message-----
From: Danny Robinson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 23, 2007 12:24 PM
To: MyFaces Discussion
Subject: Re: [Trinidad] How to add a custom JavaScript resource script
Will,
I'm not totally sure on that one, but I believe the functions parameter is
related to Trinidad ensuring any depend libraries/functions are also included
for you. From memory, I'm not certain this is really working as all the core
js libraries that are part of the framework are listed out in
CoreCommonScriptsResourceLoader anyway.
So to include a library and then call functions from it, you'd just follow the
outputScriptlet call from my last email with something like:
// output the popup javascript library
scriptLib.outputScriptlet (context, arc);
writer.startElement("script", component);
renderScriptTypeAttribute(context, arc);
renderScriptDeferAttribute(context, arc);
writer.writeText("callMyFunction();", null);
writer.endElement("script");
Thanks,
Danny
On 5/23/07, William Hoover < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> >
wrote:
Danny,
Thanks for your help! I noticed that the new LibraryScriptlet(String
libraryName, String[] functions) passes the script directly into the
libraryName. Would I just replace "YourScript" with the actual js functions
(i.e. "function(){...}") or would I use an identifier for the library name and
pass in the function names as a String array?
Thanks,
Will
-----Original Message-----
From: Danny Robinson [mailto: [EMAIL PROTECTED]
Sent: Wednesday, May 23, 2007 10:12 AM
To: MyFaces Discussion
Subject: Re: [Trinidad] How to add a custom JavaScript resource script
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
--
Chordiant Software Inc.
www.chordiant.com