Fórum
serveResource() is not calling
anand gopalan, modificado 10 Anos atrás.
serveResource() is not calling
Expert Postagens: 442 Data de Entrada: 02/03/12 Postagens Recentes
Hi,
I want to do some AJax call for that I used Jquery and call the serveResouce() in java for that, I have written like below in the view.jsp, But it is not calling serveResouce() . Please let me know why it is not calling.
include jquery
View.jsp code
Traveldetails.java
I want to do some AJax call for that I used Jquery and call the serveResouce() in java for that, I have written like below in the view.jsp, But it is not calling serveResouce() . Please let me know why it is not calling.
include jquery
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
View.jsp code
<portlet:resourceURL var="getFuelPriceUrl">
<portlet:param name="<%=Constants.CMD%>" value="5" />
</portlet:resourceURL>
.................
................
function getLocalConveyance(){
alert("calling LocalConveyance");
$(document).change(function(){
alert("inside change function");
var selectedVehicletype=$("#<portlet:namespace />selectedVehicle").val();
alert("selectedVehicletype-->"+ selectedVehicletype);
if(selectedVehicletype!=null){
alert("inside if condition");
$.ajax({
url: "${getFuelPriceUrl}",
data: fuelPrice,
cache: false,
type:'get',
datatype:'json',
success: function(data) {
}
});
}
});
}
Traveldetails.java
public void serveResource(ResourceRequest resourceRequest,ResourceResponse resourceResponse)
throws IOException, PortletException {
System.out.println("********inside serveResource()********");
String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);
if (cmd.equals("2")){
try {
System.out.println("*********inside try in serveResource()***********");
GetTravelDetails(resourceRequest, resourceResponse);
} catch (SystemException e) {
e.printStackTrace();
}
}
else if(cmd.equals("4")){
try {
System.out.println("*****calling GetAugoSuggestionData()******** ");
GetAutoSuggestionData(resourceRequest, resourceResponse);
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else if(cmd.equals("5")){
try {
System.out.println("*****calling GetLocalConveyance()******** ");
GetLocalConveyance(resourceRequest, resourceResponse);
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
try {
System.out.println("*****calling GetTravelDetailsDyns()******** ");
GetTravelDetailsDyns(resourceRequest, resourceResponse);
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void GetLocalConveyance(ResourceRequest request, ResourceResponse response) throws SystemException, IOException {
System.out.println("**********inside GetLocalConveyance******");
}
Ravi GPR, modificado 10 Anos atrás.
RE: serveResource() is not calling
Junior Member Postagens: 36 Data de Entrada: 12/01/12 Postagens Recentes
hi
instead of '$' try with 'jQuery' keyword. it may work
instead of '$' try with 'jQuery' keyword. it may work
anand gopalan, modificado 10 Anos atrás.
RE: serveResource() is not calling
Expert Postagens: 442 Data de Entrada: 02/03/12 Postagens Recentes
Hi,
I tried with that but it is not working, wonder is other AJAX call is working, only this is not calling serveResource(). Anybody please help me.
I tried with that but it is not working, wonder is other AJAX call is working, only this is not calling serveResource(). Anybody please help me.
Ravi GPR, modificado 10 Anos atrás.
RE: serveResource() is not calling
Junior Member Postagens: 36 Data de Entrada: 12/01/12 Postagens Recentes
Hi,
Try this way it may work,
var url = "<%= yourResourceURL %>" + "¶mOne=" + paramOneValue + "¶mTwo=" + paramTwoValue;
jQuery.getJSON(url, function(data) {
// you can use your call back data
}
Try this way it may work,
var url = "<%= yourResourceURL %>" + "¶mOne=" + paramOneValue + "¶mTwo=" + paramTwoValue;
jQuery.getJSON(url, function(data) {
// you can use your call back data
}
anand gopalan, modificado 10 Anos atrás.
RE: serveResource() is not calling
Expert Postagens: 442 Data de Entrada: 02/03/12 Postagens Recentes
Hi Ravi,
this is i am using to call serveResouce()
is it correct?
this is i am using to call serveResouce()
<portlet:resourceURL var="getFuelPriceUrl">
<portlet:param name="<%=Constants.CMD%>" value="5" />
</portlet:resourceURL>
is it correct?
function getLocalConveyance(){
alert("calling LocalConveyance");
$(document).change(function(){
alert("inside change function");
var selectedVehicletype=$("#<portlet:namespace />selectedVehicle").val();
var url = "<%= getFuelPriceUrl %>" + "&Constants.CMD=" + 5 ;
alert("selectedVehicletype-->"+ selectedVehicletype);
if(selectedVehicletype!=null){
alert("inside if condition");
$.ajax({
url: "${getFuelPriceUrl}",
data: fuelPrice,
cache: false,
type:'get',
datatype:'json',
jQuery.getJSON(url, function(data) {
var price=data;
var fuelprice=$("#<portlet:namespace />t02FuelPrice").val(price);
alert("fuelprice-->"+fuelprice);
});
});
}
});
}
Ravi GPR, modificado 10 Anos atrás.
RE: serveResource() is not calling
Junior Member Postagens: 36 Data de Entrada: 12/01/12 Postagens Recentes
HI,
<portlet:resourceURL var="getFuelPriceUrl">
<portlet:param name="<%=Constants.CMD%>" value="5" />
</portlet:resourceURL>
function getLocalConveyance(){
alert("calling LocalConveyance");
jQuery(document).change(function(){
alert("inside change function");
var selectedVehicletype=jQuery("#<portlet:namespace />selectedVehicle").val();
var url = "<%= getFuelPriceUrl %>";
alert("selectedVehicletype-->"+ selectedVehicletype);
if(selectedVehicletype!=null){
alert("inside if condition");
jQuery.getJSON(url, function(data) {
var price=data;
var fuelprice=jQuery("#<portlet:namespace />t02FuelPrice").val(price);
alert("fuelprice-->"+fuelprice);
});
}
});
}
<portlet:resourceURL var="getFuelPriceUrl">
<portlet:param name="<%=Constants.CMD%>" value="5" />
</portlet:resourceURL>
function getLocalConveyance(){
alert("calling LocalConveyance");
jQuery(document).change(function(){
alert("inside change function");
var selectedVehicletype=jQuery("#<portlet:namespace />selectedVehicle").val();
var url = "<%= getFuelPriceUrl %>";
alert("selectedVehicletype-->"+ selectedVehicletype);
if(selectedVehicletype!=null){
alert("inside if condition");
jQuery.getJSON(url, function(data) {
var price=data;
var fuelprice=jQuery("#<portlet:namespace />t02FuelPrice").val(price);
alert("fuelprice-->"+fuelprice);
});
}
});
}
anand gopalan, modificado 10 Anos atrás.
RE: serveResource() is not calling
Expert Postagens: 442 Data de Entrada: 02/03/12 Postagens Recentes
than you so much Ravi, for your immediate response.
Ravi GPR, modificado 10 Anos atrás.
RE: serveResource() is not calling
Junior Member Postagens: 36 Data de Entrada: 12/01/12 Postagens Recentes
Is it work or not?
anand gopalan, modificado 10 Anos atrás.
RE: serveResource() is not calling
Expert Postagens: 442 Data de Entrada: 02/03/12 Postagens Recentes
sorry for delay reply its working, thank you Ravi
Ketan Savaliya, modificado 10 Anos atrás.
RE: serveResource() is not calling
Regular Member Postagens: 117 Data de Entrada: 03/03/11 Postagens Recentes
Hi,
This is same as bellow please look into that.
http://www.liferay.com/community/forums/-/message_boards/message/27265467
Thank you,
Ketan savaliya.
This is same as bellow please look into that.
http://www.liferay.com/community/forums/-/message_boards/message/27265467
Thank you,
Ketan savaliya.
Shankar Baba, modificado 10 Anos atrás.
RE: serveResource() is not calling
Regular Member Postagens: 143 Data de Entrada: 18/10/12 Postagens Recentes
Thanks Ravi, it worked for me.