title: ADF Jdeveloper - Perform click on button using javascript on JSP
body: <p>Im trying to perform a click in a button using javascript, I want to execute a method which is supposed to run in a backing bean.</p>
  
  <p>This is my resource </p>
  
  <pre><code>       &lt;af:resource type="javascript"&gt;
            function closePopup(event) {
                //var dialog = event.getSource();
                //var popup = dialog.findComponent("pt1:b17");
                //console.log(popup);
                //popup.click();
                //$("#pt1:b17").trigger("click");
                //popup.hide();
                //event.cancel(); document.getElementById('pt1:b17')
                console.log("trigger the event");
  
                eventFire(document.getElementById(AdfPage.PAGE.findComponentByAbsoluteId('pt1:b17').getClientId()), 'click');
            }
  
            function eventFire(el, etype) {
  
                if (el.fireEvent) {
                    console.log("true");
                    el.fireEvent('on' + etype);
                }
                else {
                    console.log("false");
                    var evObj = document.createEvent('Events');
                    evObj.initEvent(etype, true, false);
                    el.dispatchEvent(evObj);
                }
            }
          &lt;/af:resource&gt;
  </code></pre>
  
  <p>Now this is my jsp code:</p>
  
  <pre><code>                                                                 &lt;af:group id="g4"&gt;
                                                                      &lt;af:commandButton text="Aceptar" id="b17"&gt;
                                                                          &lt;af:fileDownloadActionListener contentType="excelHTML" filename="#{viewScope.mbFiles.file_name}" method="#{viewScope.mbFiles.generateFile}"/&gt;
                                                                      &lt;/af:commandButton&gt;
                                                                      &lt;af:button text="test" id="buttonTest"&gt;
                                                                          &lt;af:clientListener method="closePoPup" type="action"/&gt;
                                                                      &lt;/af:button&gt;
                                                                  &lt;/af:group&gt;
  </code></pre>
  
  <p>I cant trigger the method that download my file.</p>
  
  <p>Thanks in advance.</p>