title: how to call specific method rather then serveResource method in portlet.java class from ajax call in lfieray portlet?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/13246870/how-to-call-specific-method-of-portlet-java-class-rather-then-overide-serveresou">How to call specific method of portlet.java class rather then overide serveResource method?</a>  </p>
  </blockquote>
  
  
  
  <p>I have one confusion about calling the ajax method in liferay right now am doing this way </p>
  
  <p>This is my sample view.jsp in which am just calling one method of my portlet.java class</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>now i have override  serveResource method in my portlet.java class</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>Now What i knew is from any Ajax call it will redirect to this method.
  but how can i call specific method of my porltet.java class from Ajax call?is there anyway?
  am just new bee in this Ajax and need help of you people..if anyone can guide me</p>