west007 west007 - 7 months ago 16
Javascript Question

Calling javascript from ADF page (jsff)

I have taskflow containing a .jsff page (Let's call this child page) in which we are calling javascript method on click of a button. The javascript methos is doing

element = findComponent("id")

and then doing some operation on that element. This javascript method is added to .jsff page as a resource.

This taskflow is inserted in another page (Let's call this page as parent page) as a region . Now the parent page also has an element with id ="id" which is being used in findComponent of child page, that is child page and parent page has the same id.

So does invoking of javascript from child page taskflow will find element of child page or parent page?

Sam Sam
Answer

You can use af:resource tag to add javascript function , but it would be better to add it to a page component so that the browser does not cache it

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:panelFormLayout>
 <af:resource type="javascript">
    function yourMethod(evt){ ... }
 </af:resource>
</af:panelFormLayout> 

You should read more about this.

https://blogs.oracle.com/jdevotnharvest/entry/gotcha_when_using_javascript_in