title: How to call specific method of portlet.java class rather then overide serveResource method?
body: <p>I want some help in liferay with ajax.
  Right now I am calling the ajax method from my <code>view.jsp</code> page to submit some data.</p>
  
  <p>Here is sample code I am using in <code>view.jsp</code>:</p>
  
  <pre><code>&lt;%@ include file="/init.jsp"%&gt;
  
  &lt;portlet:actionURL name="AddTest" var="add1" /&gt;
  &lt;portlet:resourceURL id="AddTest" var="AddTest"&gt;&lt;/portlet:resourceURL&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript"&gt;
      function addToDo(addToDo){
          var todo =document.getElementById('toDo').value;
          $.ajax({
              url :addToDo,            
                data: {"todo":todo,"CMD":"addToDo"},
                type: "GET",
                dataType: "text",
              success: function(data) {              
                    $("#toDoList").html(data);
              }
          });
      }
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;portlet:resourceURL var="addToDo" id="addToDo"&gt;&lt;/portlet:resourceURL&gt;
  
      &lt;form&gt;
          &lt;input type="text" name="toDo" id="toDo"&gt;
          &lt;button name="Add" type="button" onclick="addToDo('&lt;%=addToDo%&gt;')"&gt;Add&lt;/button&gt;
          &lt;div id="toDoList"&gt;
  
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>and in my <code>portlet.java</code> class there is one method which is called by this ajax call: </p>
  
  <pre><code>@Override
  public void serveResource(ResourceRequest request, ResourceResponse response){
      if(request.getParameter("CMD").equals("addToDo")) {
  
          System.out.println("came here for add");
  
          mediatype userToDo = new mediatypeImpl();
          //userToDo.setMediaId(12345);
          try {
              userToDo.setPrimaryKey((CounterLocalServiceUtil.increment()));
              userToDo.setMedianame(request.getParameter("todo"));
              mediatypeLocalServiceUtil.addmediatype(userToDo);
          }
          catch (SystemException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>So my question is that right now it is just caling by default <code>@override</code> method from any ajax class.
  But how can I call specific method of <code>portlet.java</code> class on ajax call?</p>
  
  <p>I am new bee in ajax. So please guide me anyways u can.....</p>
  
  <p>I got following error when calling ajax with url of following</p>
  
  <pre><code>&lt;portlet:actionURL name="ajax_AddAdvertise" var="addToDo" windowState="&lt;%= LiferayWindowState.EXCLUSIVE.toString()%&gt;"&gt; &lt;/portlet:actionURL&gt;
  
  
  
  06:47:03,705 ERROR [http-bio-8080-exec-23][render_portlet_jsp:154] java.lang.NoSuchMethodException: emenu.advertise.portlet.RestaurantPortlet.ajax_AddAdvertise(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
      at java.lang.Class.getMethod(Class.java:1605)
  </code></pre>
  
  <p>my process action method as follows</p>
  
  <pre><code> @ProcessAction(name = "ajax_AddAdvertise")
      public void ajax_AddAdvertise(ResourceRequest request,ResourceResponse response) {
  
  }
  </code></pre>