Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8787011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:46:41+00:00 2026-06-13T21:46:41+00:00

Possible Duplicate: How to call specific method of portlet.java class rather then overide serveResource

  • 0

Possible Duplicate:
How to call specific method of portlet.java class rather then overide serveResource method?

I have one confusion about calling the ajax method in liferay right now am doing this way

This is my sample view.jsp in which am just calling one method of my portlet.java class

<%@ include file="/init.jsp"%>
<portlet:actionURL name="AddTest" var="add1" />
<portlet:resourceURL id="AddTest" var="AddTest"></portlet:resourceURL>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

 <script type="text/javascript">
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);
        }
    });
}
 </script>
</head>

<body>

<portlet:resourceURL var="addToDo" id="addToDo"></portlet:resourceURL>
<form>
<input type="text" name="toDo" id="toDo">
<button name="Add" type="button" onclick="addToDo('<%=addToDo%>')">Add</button>
<div id="toDoList">


</div>
</form>


</body>
</html> 

now i have override serveResource method in my portlet.java class

@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();
                }

            }
        }

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:46:43+00:00Added an answer on June 13, 2026 at 9:46 pm

    how can i call specific method of my porltet.java class from Ajax call

    Which specific method you are referring here ?

    As when you execute any resourceURL it will call serverResource method only. Same as when you execute any actionURL, it will call processAction method only.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to call a method of another Class? i have 2 classes.
Possible Duplicate: How to call one batch file after another I have a batch
Possible Duplicate: PHP call class in class returns error:500 I have code that looks
Possible Duplicate: Call class instance method while debugging in eclipse Is there a way
Possible Duplicate: How to call base.base.method()? I have some trouble with Inheritance in C#.
Possible Duplicate: CakePHP: Call to a member function find() on a non-object I have
Possible Duplicate: C++ Vector Pointers to Objects Does std::list::remove method call destructor of each
Possible Duplicate: Why is the 'this' keyword required to call an extension method from
Possible Duplicate: javascript object, access variable property name? I'm trying to call a method
Possible Duplicate: Java - repaint(x, y, w, h) doesn't call paintComponent? (with SSCCE) I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.