7 Replies Latest reply on Oct 27, 2017 11:40 AM by Moe_ADF_541

    Invoke a button 'ActionEvent' using Javascript

    Moe_ADF_541

      Dear Experts,

       

      I want to be able to click an <af:button/> using javascript via a <button> element. For that I have followed this sample:

      Invoke button action (ActionEvent) and value change listener using JavaScript- Oracle ADF – Ashish Awasthi's Blog (Jdev/…

       

      However the event does not seem to be launching in any way. I have inserted log messages in order to see what's happening in the browser, and it seems that all the log messages are successfully printed.

       

      <?xml version='1.0' encoding='UTF-8'?>

      <!DOCTYPE html>

      <f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">

          <af:document title="Test.jsf" id="d1">

              <af:form id="f1">

                  <af:resource type="javascript">

                    function callButtonAction() {

                        console.log(456);

                        //Method to get component using id (here button is top container)

                        var button = AdfPage.PAGE.findComponentByAbsoluteId('b1');

                        console.log(button);

                        //Method to queue ActionEvent from component

                        //AdfActionEvent.queue(button, button.getPartialSubmit());

                        var actionEvent = new AdfActionEvent(button);

                        actionEvent.forceFullSubmit();

                        actionEvent.noResponseExpected();

                        actionEvent.queue();

                        console.log('wselna111');

                    }

                  </af:resource>

                  <af:panelStretchLayout id="psl1" topHeight="50px">

                      <f:facet name="start"/>

                      <f:facet name="end"/>

                      <f:facet name="top">

                          <af:panelGroupLayout id="pgl1" layout="horizontal">

                              <button onclick="callButtonAction()">

                                  activate JS

                                  <!--<af:clientListener method="callButtonAction()" type="onClick"/>-->

                              </button>

                              <af:button text="button 1" id="b1" actionListener="#{pageFlowScope.TestBean.buttonAction}"

                                         visible="false"/>

                          </af:panelGroupLayout>

                      </f:facet>

                      <f:facet name="bottom"/>

                      <f:facet name="center"/>

                  </af:panelStretchLayout>

              </af:form>

          </af:document>

      </f:view>

       

      This is the output on the browser log:

       

       

      I uploaded a use case at: https://drive.google.com/open?id=0B1puO86WZQKMdXdDSFNUSzNFTDQ

       

      Can someone kindly tell me what's the problem here? or how can I further troubleshoot this? Is the violation displayed an indication of the cause?

      Thanks very much in advance.

       

      Best Regards,

       

      JDeveloper 12.2.1.2