You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Laurie Harper <la...@holoweb.net> on 2006/02/22 06:44:18 UTC

ADF Faces javascript rendering

The Tomahawk components 'inject' Javascript file references into the 
<head> section of the response by using a filter to buffer and 
post-process the response. I'm assuming ADF Faces has some mechanism for 
injecting Javascript too, but I can't seem to track it down...

I've found the code that handles serving static resources, just not the 
code responsible for injecting references to Javascript files. The 
reason I'm looking for it is so I can make a component library I'm 
working on use it.

Can anyone give me a pointer to the right area in the ADF Faces code, or 
even better a quick explanation of how to use it to do what I want?

Thanks,

L.


Re: ADF Faces javascript rendering

Posted by Laurie Harper <la...@holoweb.net>.
Mike Kienenberger wrote:
> On 2/22/06, Laurie Harper <la...@holoweb.net> wrote:
>> Maybe it would make sense to move Tomahawk's AddResources / Filter based
>> stuff into commons so it can be re-used across Tomahawk, ADFF, Tobago
>> and other component libraries?
> 
> I don't see any reason why we can't move that stuff into commons (and
> actually, I figured it was already in commons), now that we have a
> commons jar.   It's intended as an end-user API.  Please open a JIRA
> issue so we don't forget. You've probably noticed that we're still
> discussing how commons is going to work :)
> 
> Maybe it hasn't been done up to this point because the extensions
> filter isn't included in commons yet.

Yeah, that's what I meant; some stuff is in commons already, some stuff 
is in Tomahawk. Actually, I think most stuff except the filter itself, 
and maybe the default resource loader impl, are in commons. I added 
TOMAHAWK-155 to request the filter itself be moved over too.

L.


Re: ADF Faces javascript rendering

Posted by Mike Kienenberger <mk...@gmail.com>.
On 2/22/06, Laurie Harper <la...@holoweb.net> wrote:
> Maybe it would make sense to move Tomahawk's AddResources / Filter based
> stuff into commons so it can be re-used across Tomahawk, ADFF, Tobago
> and other component libraries?

I don't see any reason why we can't move that stuff into commons (and
actually, I figured it was already in commons), now that we have a
commons jar.   It's intended as an end-user API.  Please open a JIRA
issue so we don't forget. You've probably noticed that we're still
discussing how commons is going to work :)

Maybe it hasn't been done up to this point because the extensions
filter isn't included in commons yet.

-Mike

Re: ADF Faces javascript rendering

Posted by Laurie Harper <la...@holoweb.net>.
Adam Winer wrote:
> Laurie,
> 
> We use a Scriptlet API down in :
>      oracle.adfinternal.view.faces.renderkit.core.xhtml.jsLibs
> ... the basic gist of which is that a Renderer can say
> "hey, I need function foo()", and the Scriptlet API
> figures out whether that means importing a lib, or
> writing out an in-place script, and if so, whether it's already
> been rendered once.
> 
> Instead of using a Filter to inject into <head>,  we currently
> blow off the notion that <script> elements can only be in
> <head>.  Evil, perhaps, but there's not a browser that really
> cares, and practical considerations trumped HTML purity.
> But since the details are hidden inside of the Scriptlets, they
> could instead just add the scripts to a list that later gets
> injected by a Filter.

OK, people keep telling me 'we just write script tags inline' so maybe 
I'll just follow the herd ;-) My goal was to be able to say, for a 
component library I'm working on, that 'if you are using Tomahawk or ADF 
Faces, you don't need any additional configuration' so if ADFF is 
already working this way, it wouldn't hurt for my components to do 
likewise when deployed alongside ADFF...

> Note that this code is currently in "adfinternal", which
> means that it is not a public API, and is not considered
> legit for code external to ADF Faces to extend.  One
> of my major goals for the ADF Faces codebase is to
> extract a public API from the current adfinternal rendering
> APIs, which reminds me I need to post some support
> for John's api/impl split e-mail... :)

That's a good point. If I do decide to do anything that relies on these 
APIs I'll have to clearly flag what versions of ADFF are compatible.

Maybe it would make sense to move Tomahawk's AddResources / Filter based 
stuff into commons so it can be re-used across Tomahawk, ADFF, Tobago 
and other component libraries?

L.

> 
> -- Adam
> 
> 
> On 2/21/06, Laurie Harper <la...@holoweb.net> wrote:
>> The Tomahawk components 'inject' Javascript file references into the
>> <head> section of the response by using a filter to buffer and
>> post-process the response. I'm assuming ADF Faces has some mechanism for
>> injecting Javascript too, but I can't seem to track it down...
>>
>> I've found the code that handles serving static resources, just not the
>> code responsible for injecting references to Javascript files. The
>> reason I'm looking for it is so I can make a component library I'm
>> working on use it.
>>
>> Can anyone give me a pointer to the right area in the ADF Faces code, or
>> even better a quick explanation of how to use it to do what I want?
>>
>> Thanks,
>>
>> L.
>>
>>
> 


Re: ADF Faces javascript rendering

Posted by Adam Winer <aw...@gmail.com>.
Laurie,

We use a Scriptlet API down in :
     oracle.adfinternal.view.faces.renderkit.core.xhtml.jsLibs
... the basic gist of which is that a Renderer can say
"hey, I need function foo()", and the Scriptlet API
figures out whether that means importing a lib, or
writing out an in-place script, and if so, whether it's already
been rendered once.

Instead of using a Filter to inject into <head>,  we currently
blow off the notion that <script> elements can only be in
<head>.  Evil, perhaps, but there's not a browser that really
cares, and practical considerations trumped HTML purity.
But since the details are hidden inside of the Scriptlets, they
could instead just add the scripts to a list that later gets
injected by a Filter.

Note that this code is currently in "adfinternal", which
means that it is not a public API, and is not considered
legit for code external to ADF Faces to extend.  One
of my major goals for the ADF Faces codebase is to
extract a public API from the current adfinternal rendering
APIs, which reminds me I need to post some support
for John's api/impl split e-mail... :)

-- Adam


On 2/21/06, Laurie Harper <la...@holoweb.net> wrote:
> The Tomahawk components 'inject' Javascript file references into the
> <head> section of the response by using a filter to buffer and
> post-process the response. I'm assuming ADF Faces has some mechanism for
> injecting Javascript too, but I can't seem to track it down...
>
> I've found the code that handles serving static resources, just not the
> code responsible for injecting references to Javascript files. The
> reason I'm looking for it is so I can make a component library I'm
> working on use it.
>
> Can anyone give me a pointer to the right area in the ADF Faces code, or
> even better a quick explanation of how to use it to do what I want?
>
> Thanks,
>
> L.
>
>

Re: ADF Faces javascript rendering

Posted by Laurie Harper <la...@holoweb.net>.
Mike, thanks for the link. Yes, I'm familiar with the AddResources stuff 
in Tomahawk, but was looking for the equivalent functionality in ADF 
Faces so I can inter-operate with either.

L.

Mike Kienenberger wrote:
> Have you looked at this?
> 
> http://wiki.apache.org/myfaces/External_Resources
> 
> 
> On 2/22/06, Laurie Harper <la...@holoweb.net> wrote:
>> The Tomahawk components 'inject' Javascript file references into the
>> <head> section of the response by using a filter to buffer and
>> post-process the response. I'm assuming ADF Faces has some mechanism for
>> injecting Javascript too, but I can't seem to track it down...
>>
>> I've found the code that handles serving static resources, just not the
>> code responsible for injecting references to Javascript files. The
>> reason I'm looking for it is so I can make a component library I'm
>> working on use it.
>>
>> Can anyone give me a pointer to the right area in the ADF Faces code, or
>> even better a quick explanation of how to use it to do what I want?
>>
>> Thanks,
>>
>> L.
>>
>>
> 


Re: ADF Faces javascript rendering

Posted by Mike Kienenberger <mk...@gmail.com>.
Have you looked at this?

http://wiki.apache.org/myfaces/External_Resources


On 2/22/06, Laurie Harper <la...@holoweb.net> wrote:
> The Tomahawk components 'inject' Javascript file references into the
> <head> section of the response by using a filter to buffer and
> post-process the response. I'm assuming ADF Faces has some mechanism for
> injecting Javascript too, but I can't seem to track it down...
>
> I've found the code that handles serving static resources, just not the
> code responsible for injecting references to Javascript files. The
> reason I'm looking for it is so I can make a component library I'm
> working on use it.
>
> Can anyone give me a pointer to the right area in the ADF Faces code, or
> even better a quick explanation of how to use it to do what I want?
>
> Thanks,
>
> L.
>
>

Re: ADF Faces javascript rendering

Posted by Rogers Reilly <ro...@s-rod.com>.
Werner Punz wrote:

>Laurie Harper schrieb:
>  
>
>>The Tomahawk components 'inject' Javascript file references into the
>><head> section of the response by using a filter to buffer and
>>post-process the response. I'm assuming ADF Faces has some mechanism for
>>injecting Javascript too, but I can't seem to track it down...
>>
>>I've found the code that handles serving static resources, just not the
>>code responsible for injecting references to Javascript files. The
>>reason I'm looking for it is so I can make a component library I'm
>>working on use it.
>>
>>Can anyone give me a pointer to the right area in the ADF Faces code, or
>>even better a quick explanation of how to use it to do what I want?
>>
>>Thanks,
>>
>>    
>>
>Laurie, cannot help you there, but a minor sidequestion, did you use my
>dojo hooks I provided in the sandbox?
>If yes please give me feedback if you need something changed
>or added, now is a perfect time for doing it, the whole dojo base will
>be moved into Tomahawk after 1.1.2, and then it will be much harder to
>break existing interfaces if needed.
>The reason why I am asking is that I need comments and feedback from
>people who do serious component development so that I get more insight
>on what is needed (for now I only have the stuff in I need)
>
>
>
>  
>
I haven't made a full-blown Dojo component yet, but I have used the 
<af:inputHidden value="#{backingBean.var}" id="myId" /> component of ADF 
with Dojo widgets, passing the widget a simple onFoo function along the 
lines of 'document.getElementById('myId').value = 
MyWidget.getSomeValue();' to sync up the widget with JSF.  (note- you 
can also submit a display:none CommandButton in this onFoo function, and 
do a Partial Page Refresh ... very cool!)

Now, I've just done this hookup with a Facelet--which works fine for 
now, can even be packaged into a tag if I want--and not an actual 
component, so I can't say what I'd want from a platform perspective to 
facilitate this kind of simple Dojo/JS-to-JSF integration.  (toDoList[0] 
= learn custom components)

Did want to share the pattern, though, as it seems like the kind of 
thing MyFaces could facilitate.

Re: ADF Faces javascript rendering

Posted by Laurie Harper <la...@holoweb.net>.
Werner Punz wrote:
> Laurie, cannot help you there, but a minor sidequestion, did you use my
> dojo hooks I provided in the sandbox?
> If yes please give me feedback if you need something changed
> or added, now is a perfect time for doing it, the whole dojo base will
> be moved into Tomahawk after 1.1.2, and then it will be much harder to
> break existing interfaces if needed.
> The reason why I am asking is that I need comments and feedback from
> people who do serious component development so that I get more insight
> on what is needed (for now I only have the stuff in I need)

I had a look through (some of) your Dojo-related code, but haven't used 
it directly. As you know, I have code of my own in this area ;-)

L.


Re: ADF Faces javascript rendering

Posted by Werner Punz <we...@gmx.at>.
Laurie Harper schrieb:
> The Tomahawk components 'inject' Javascript file references into the
> <head> section of the response by using a filter to buffer and
> post-process the response. I'm assuming ADF Faces has some mechanism for
> injecting Javascript too, but I can't seem to track it down...
> 
> I've found the code that handles serving static resources, just not the
> code responsible for injecting references to Javascript files. The
> reason I'm looking for it is so I can make a component library I'm
> working on use it.
> 
> Can anyone give me a pointer to the right area in the ADF Faces code, or
> even better a quick explanation of how to use it to do what I want?
> 
> Thanks,
> 
Laurie, cannot help you there, but a minor sidequestion, did you use my
dojo hooks I provided in the sandbox?
If yes please give me feedback if you need something changed
or added, now is a perfect time for doing it, the whole dojo base will
be moved into Tomahawk after 1.1.2, and then it will be much harder to
break existing interfaces if needed.
The reason why I am asking is that I need comments and feedback from
people who do serious component development so that I get more insight
on what is needed (for now I only have the stuff in I need)