Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Javascript function doesn't run on JSFF page load but runs upon refreshing the page

Nisar AhmedDec 29 2015 — edited Dec 29 2015

A little background first:- I'm a frontend developer who uses jDeveloper to build templates/pages. I also handle client side scripting via the use of af:clientListerner tags. But my knowledge on the backend related stuff (beans, triggers, actions) etc. is next to none. Thus, I'll be using very basic technical words to describe my problem.


Case Scenario:


Let's say I have two JSFF pages, first.jsff and second.jsff


In first.jsff, I have a command link which navigates to second.jsff. Inside this page, I have a javascript function which I need to run when the UI is rendered. But as soon as second.jsff loads up, my JS function never fires. Only when I refresh the page do I see it run. This what second.jsff looks like:

<?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" xmlns:f="http://java.sun.com/jsf/core">         

   <af:panelGroupLayout id="pgl17" styleClass="mainBox AFStretchWidth">

       <af:resource type="javascript">

            function runOnLoad(){

                  alert("Hello world");

           }

           runOnLoad();

        </af:resource>

        /*   other ADF components go below this line

        .

        .

        .

        */

   </af:panelGroupLayout>

</jsp:root>

So I see the alert only when I refresh the page (i.e. after the redirection happens, I have to refresh the page to make the JS execute)

What am I missing here?

jDeveloper version is 11.1.1.9.0

This post has been answered by Sameh Nassar on Dec 29 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 26 2016
Added on Dec 29 2015
8 comments
1,454 views