The recommended way to add scripting to your JSPX page is via the
metaContainer <facet> tag. You add the
metaContainer <facet> within the
<af:document> tag. You can group your scripts within the
metaContainer <facet> using an
<af:group> tag. The actual script should be added within an
<afh:script> or a
<trh:script> tag. Adding Javascript to your JSPX page by directly placing a
<script> tag is not recommended because it could have undesired side effects related to the proper resizing of the components in the page.
Example:
<f:facet name="metaContainer">
<af:group>
<afh:script source="/js/YourJsLibrary.js"/>
<afh:script>
function someFunction()
{
…
}
</afh:script>
</af:group>
</f:facet>
Context:
JSPX Page
Nice post Nick, which reminded me something that I read in Frank's new book
ReplyDelete( http://www.amazon.co.uk/Oracle-Fusion-Developer-Guide-Applications/dp/0071622543/ref=ntt_at_ep_dpt_1 ).
According to the book, the preferred way is to use af:resource tag (http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_resource.html).
which optimizes the loading of Javascript etc (more in Frank book).
Hope this helps too. :)
Thanks for the pointer Spyro! Also, take a look at related post Bit #1.
ReplyDeleteRespect Nick. You are always ahead of me :)
ReplyDeleteWhy not af:resource inside the metaContainer facet??
ReplyDeleteGeorge, as Spyros said in his comment, that would do as well. The approach mentioned in the post, is how we added Javascript to resolve issues related to proper resizing of components on the page. It seems to be working well.
ReplyDeleteHi,
ReplyDeleteDo you have any info. to read a cookie inside ADF
I need to add into my jspx page. where should I put it so that it appears under head tag . Kindly help
ReplyDeleteThanks in advance
Hi.. I am new to oracle jDeveloper and to Java. Can u pls let me know how to write a javascript for calling a function inside jspx page?
ReplyDeleteTIA