title: p:remoteCommand run on page load instead of button's onclick event in javascript
body: <p>I have to call a remote command through javascript. The remote command is working fine but it invokes on page load instead of the button's onclick event.</p>
  
  <p>Following is my xhtml file code as well as the bean code.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:h="http://java.sun.com/jsf/html"&gt;
  
  &lt;h:head&gt;
      &lt;title&gt;Crowd Flow&lt;/title&gt;
  &lt;/h:head&gt;
  
  &lt;f:event listener="#{task.loadTaskByTaskId(param['task_id'])}"
      type="preRenderView" /&gt;
  
  &lt;h:body bgcolor="white"&gt;
  
      &lt;h:outputScript&gt;
          function getCurrentLocation() {
              testingCommand();           
          }
      &lt;/h:outputScript&gt;
  
      &lt;h:panelGroup id="header" layout="block"&gt;
          &lt;h3&gt;Welcome to the task.&lt;/h3&gt;
      &lt;/h:panelGroup&gt;
  
  
      &lt;h:panelGroup id="taskLayout" layout="block"&gt;
          &lt;h:outputText value="Category is #{task.taskCategory}"&gt;&lt;/h:outputText&gt;
          &lt;h:outputText value="Task id is is #{task.id}"&gt;&lt;/h:outputText&gt;
  
          &lt;c:if test="#{param['task_id']=='9'}"&gt;
              &lt;h:form style="width:400px;" id="newTagTaskForm"&gt;
  
                  &lt;p:remoteCommand name="testingCommand"
                          actionListener="#{task.testingCommand()}" autoRun="false" /&gt;
  
                  Task Name : &lt;h:outputText id="taskName"
                      value="#{task.newPlaceTagTask.name}"&gt;&lt;/h:outputText&gt;
                  &lt;br /&gt;
                  Task Description : &lt;h:outputText id="taskDescription"
                      value="#{task.newPlaceTagTask.description}"&gt;&lt;/h:outputText&gt;
                  &lt;br /&gt;
                  Address : &lt;h:outputText id="taskAddress"
                      value="#{task.newPlaceTagTask.location.address}"&gt;&lt;/h:outputText&gt;
                  &lt;br /&gt;
                  Image : &lt;h:graphicImage width="50" height="50"
                      url="#{task.newPlaceTagTask.location.image}" /&gt;
                  &lt;br /&gt;
                  &lt;h:inputHidden value="#{task.userId}" id="taskPlaceTagUserId"
                      name="taskPlaceTagUserId" /&gt;
  
                  &lt;h:inputHidden value="#{task.newPlaceTagTask.location.id}"
                      id="taskPlaceTagLocationId" name="taskPlaceTagLocationId" /&gt;
  
                  &lt;h:commandButton id="testing" value="submit" type="submit" onclick="getCurrentLocation();return false;" &gt;&lt;/h:commandButton&gt;
              &lt;/h:form&gt;
          &lt;/c:if&gt;
      &lt;/h:panelGroup&gt;
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the bean function, bean is view scoped.</p>
  
  <pre><code>package com.project.crowdsource.beans;
  
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.ViewScoped;
  
  @ManagedBean(name="task")
  @ViewScoped
  
  public class TaskBean implements Serializable {
      public TaskBean() {
          //initiating user's data access object.
          taskDao = new TaskDAO();
      }
  
      public String testingCommand() {
          System.out.println("in action testing command");
  
          return "";
      }   
  }
  </code></pre>
  
  <p>Any help would be highly appreciated.</p>
  
  <p>Thanks,</p>