掲示板
Unable to connect to Portlet class from AJAX request .
11年前 に Ravi Kiran によって更新されました。
Unable to connect to Portlet class from AJAX request .
Junior Member 投稿: 98 参加年月日: 11/12/12 最新の投稿
Hi ,
I am using Liferay 6.1 CE for Portal Application development .
I am trying to Use Jquery with AJAX in my Portlet .
This is my JSP Page as shown :
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<script type="text/javascript">
$(document).ready(function(){
jQuery.ajax({
url:'<portlet:resourceURL id="ajax" ></portlet:resourceURL>',
data: {id:data},
type: 'POST',
datatype:'json',
success: function(respData) {
alert(respData);
}
});
});
</script>
This is my MVC Portlet class
public class ArrayPortlet extends MVCPortlet {
@Resource(name="ajax")
public void testAjax(
PortletConfig config, ResourceRequest request, ResourceResponse response)
throws Exception {
}
}
But i am unable to connect to my Java class .
Could somebody please help me . Thanks .
I am using Liferay 6.1 CE for Portal Application development .
I am trying to Use Jquery with AJAX in my Portlet .
This is my JSP Page as shown :
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<script type="text/javascript">
$(document).ready(function(){
jQuery.ajax({
url:'<portlet:resourceURL id="ajax" ></portlet:resourceURL>',
data: {id:data},
type: 'POST',
datatype:'json',
success: function(respData) {
alert(respData);
}
});
});
</script>
This is my MVC Portlet class
public class ArrayPortlet extends MVCPortlet {
@Resource(name="ajax")
public void testAjax(
PortletConfig config, ResourceRequest request, ResourceResponse response)
throws Exception {
}
}
But i am unable to connect to my Java class .
Could somebody please help me . Thanks .
11年前 に Raja Nagendra Kumar によって更新されました。
RE: Unable to connect to Portlet class from AJAX request .
Expert 投稿: 484 参加年月日: 06/03/02 最新の投稿
Can try it as href
<a href='<portlet:resourceURL>
<portlet:param name="vehicleId" value="${vehicleInfo.pk}" />
</portlet:resourceURL>'
This could tell you if the issue with ajax call firing issue or server side configuration issue.
Regards,
Nagendra
<a href='<portlet:resourceURL>
<portlet:param name="vehicleId" value="${vehicleInfo.pk}" />
</portlet:resourceURL>'
This could tell you if the issue with ajax call firing issue or server side configuration issue.
Regards,
Nagendra
11年前 に Amit Doshi によって更新されました。
RE: Unable to connect to Portlet class from AJAX request .
Liferay Master 投稿: 550 参加年月日: 10/12/29 最新の投稿Ravi Kiran:
Hi ,
I am using Liferay 6.1 CE for Portal Application development .
I am trying to Use Jquery with AJAX in my Portlet .
This is my JSP Page as shown :
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<script type="text/javascript">
$(document).ready(function(){
jQuery.ajax({
url:'<portlet:resourceURL id="ajax" ></portlet:resourceURL>',
data: {id:data},
type: 'POST',
datatype:'json',
success: function(respData) {
alert(respData);
}
});
});
</script>
This is my MVC Portlet class
public class ArrayPortlet extends MVCPortlet {
@Resource(name="ajax")
public void testAjax(
PortletConfig config, ResourceRequest request, ResourceResponse response)
throws Exception {
}
}
But i am unable to connect to my Java class .
Could somebody please help me . Thanks .
Hi Ravi,
According to my knowledge you can't use @Resource(name="ajax"). Because there are not parameter in TLD through which you can bind it to the controller.
You have to use the serveResource method only.
11年前 に Ravi Kiran によって更新されました。
RE: Unable to connect to Portlet class from AJAX request .
Junior Member 投稿: 98 参加年月日: 11/12/12 最新の投稿
I have removed the Annotation @Resource(name="ajax") , but i am unable to connect to the Java class from Ajax Request .
Could anybody please tell me how to connect to Java Portlet class from the Ajax Request .
Could anybody please tell me how to connect to Java Portlet class from the Ajax Request .
11年前 に Amit Doshi によって更新されました。
RE: Unable to connect to Portlet class from AJAX request .
Liferay Master 投稿: 550 参加年月日: 10/12/29 最新の投稿Ravi Kiran:
I have removed the Annotation @Resource(name="ajax") , but i am unable to connect to the Java class from Ajax Request .
Could anybody please tell me how to connect to Java Portlet class from the Ajax Request .
And also make the method name as serveResource.
11年前 に Amit Doshi によって更新されました。
RE: Unable to connect to Portlet class from AJAX request .
Liferay Master 投稿: 550 参加年月日: 10/12/29 最新の投稿
Add more on my own comment.
Make in Controller method as :-
@Override
public void serveResource(final ResourceRequest resourceRequest,
final ResourceResponse resourceResponse) throws IOException, PortletException
{
}
Thanks & Regards,
Amit Doshi
Make in Controller method as :-
@Override
public void serveResource(final ResourceRequest resourceRequest,
final ResourceResponse resourceResponse) throws IOException, PortletException
{
}
Thanks & Regards,
Amit Doshi
11年前 に Ravi Kiran によって更新されました。
RE: Unable to connect to Portlet class from AJAX request .
Junior Member 投稿: 98 参加年月日: 11/12/12 最新の投稿
I tried the following , but still i am unsuccessful .
This is my JSP Page :
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<portlet:actionURL name="User" var="UserURL"/>
<script type="text/javascript">
$(document).ready(function(){
jQuery.ajax({
url:'<portlet:resourceURL id="resourceURL" var="resourceURL" />',
data: {id:data},
type: 'POST',
datatype:'json',
success: function(respData) {
alert(respData);
}
});
});
</script>A
This is under Java :
package com;
import java.io.IOException;
import javax.portlet.PortletException;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import com.liferay.util.bridges.mvc.MVCPortlet;
public class Test extends MVCPortlet {
@Override
public void serveResource(final ResourceRequest resourceRequest,
final ResourceResponse resourceResponse) throws IOException, PortletException
{
System.out.println("Hi Madahava Rao");
}
}
Am i doing anythig wrong ??
This is my JSP Page :
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<portlet:actionURL name="User" var="UserURL"/>
<script type="text/javascript">
$(document).ready(function(){
jQuery.ajax({
url:'<portlet:resourceURL id="resourceURL" var="resourceURL" />',
data: {id:data},
type: 'POST',
datatype:'json',
success: function(respData) {
alert(respData);
}
});
});
</script>A
This is under Java :
package com;
import java.io.IOException;
import javax.portlet.PortletException;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import com.liferay.util.bridges.mvc.MVCPortlet;
public class Test extends MVCPortlet {
@Override
public void serveResource(final ResourceRequest resourceRequest,
final ResourceResponse resourceResponse) throws IOException, PortletException
{
System.out.println("Hi Madahava Rao");
}
}
Am i doing anythig wrong ??
11年前 に Zankar Shah によって更新されました。
RE: Unable to connect to Portlet class from AJAX request .
Regular Member 投稿: 106 参加年月日: 07/10/03 最新の投稿
Hello
Possibly the way you are passing url, that could be an issue.
I just tried to do the same and it works perfectly for me
My jsp:
"
"
My js:
"
"
My Java:
Possibly the way you are passing url, that could be an issue.
I just tried to do the same and it works perfectly for me
My jsp:
"
<portlet:resourceURL id="postURL" var="postURL">
<portlet:param name="protocol" value="http"></portlet:param>
</portlet:resourceURL>
<input type='hidden' id='postURL' value='${postURL}'/>
"
My js:
"
function accessHttp(){
var ajaxData = {
inputURL : $("#httpURLInput").val()
};
var url = $("#postURL").val();
alert(url);
$.ajax({
url: url,
data: ajaxData
}).done(function() {
alert("done");
});
}
"
My Java:
public class ContentUploaderPortlet extends MVCPortlet{
@Override
public void serveResource(ResourceRequest request, ResourceResponse response) throws IOException,PortletException{
System.out.println("in hererererere");
String protocol = request.getParameter("protocol");
String url = request.getParameter("inputURL");
System.out.println("protocol is "+protocol+"---"+url);
}
}
11年前 に Amit Doshi によって更新されました。
RE: Unable to connect to Portlet class from AJAX request .
Liferay Master 投稿: 550 参加年月日: 10/12/29 最新の投稿
Hi Ravi,
I checked implementing your code in my Project.
I found the problem is in your JAVAScript code that you had written. I now modified your code as below :-
The problem in your code is as below :-
1) use $ instead of jQuery in your ajax call.
2) data: {id:data}, you can't use data inside id, it's reserved word so. make it as data: {id:"f"}
Hope now it will solve your problem.
Thanks & Regards,
Amit Doshi
I checked implementing your code in my Project.
I found the problem is in your JAVAScript code that you had written. I now modified your code as below :-
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url:'<portlet:resourceURL />',
data: {id:"f"},
type: 'POST',
datatype:'json',
success: function(respData) {
alert(respData);
}
});
});
</script>
The problem in your code is as below :-
1) use $ instead of jQuery in your ajax call.
2) data: {id:data}, you can't use data inside id, it's reserved word so. make it as data: {id:"f"}
Hope now it will solve your problem.
Thanks & Regards,
Amit Doshi
9年前 に Lucian Alexandrescu によって更新されました。
RE: Unable to connect to Portlet class from AJAX request .
New Member 投稿: 10 参加年月日: 14/04/16 最新の投稿
Hi Doshi,
It is possible to make this call from portal theme?
Thanks in advance!
It is possible to make this call from portal theme?
Thanks in advance!