5 Replies Latest reply on Feb 14, 2013 8:01 AM by Frank Nimphius-Oracle

    Call Javascript function on ADF

      Hi All Experts,

      I am having a problem working with javascript on adf.
      Actually I have javascript function called makeHighLight() and too many input text fields are there.
      And i want to call javascript function as i mentioned above.
      I can call js function using a clientListener on my input text field. But I have too many fields.
      I don't want to set client listener on each of my text fields. Is there any way to do this.

      Please help!
        • 1. Re: Call Javascript function on ADF
          Frank Nimphius-Oracle

          depends on how you want your JS function to be triggered. If the function is triggered by a valueChange event (or another event related to an input text field) then you will have to add the clientListener component to all of the input text fields. If the function is triggered e.g by a command button then you can lookup the input text component starting from the ADfPage.PAGE root object using fincComponentByAbsoluteId()

          1 person found this helpful
          • 2. Re: Call Javascript function on ADF
            you can try something like this...jquery...

            for (String focusField : focusFieldsList)
            StringBuilder script = new StringBuilder();
            script.append("var textInput = ");
            script.append("if(textInput != null){");
            script.append("textInput.setInlineStyleProperty('background-color', 'Yellow');");
            1 person found this helpful
            • 3. Re: Call Javascript function on ADF
              Thank for reply. Now i am using "addEventListener" for my fields.
              Its working if i set clientListener on my fields directly, I mean that when not using addEventListener its return ID.
              In this situation "evt.getSource().getClientId()" return nothing and alert isn't work. I thought that that will return fields ID which i clicked.

              <af:clientListener method="funcOnLoad" type="load"/>
              <af:resource type="javascript">

              function funcOnLoad() {
              document.addEventListener('click', makeHighLight, false);

              function makeHighLight(evt){           
              • 4. Re: Call Javascript function on ADF
                Suresh Karunarathne
                Try to set ClientListner on CommandButton and get all textFields value on that function
                • 5. Re: Call Javascript function on ADF
                  Frank Nimphius-Oracle

                  your JavaScript listens for a click on the document, not necessarily the component. Even if this would do what you want, is it intended that a click on a button is highlighted too? Also what if I tab into a field? maybe you should start with the use case of what you are trying to do just to see if there is a better option