掲示板

serveResource() is not calling

10年前 に anand gopalan によって更新されました。

serveResource() is not calling

Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
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
<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******");

}


thumbnail
10年前 に Ravi GPR によって更新されました。

RE: serveResource() is not calling

Junior Member 投稿: 36 参加年月日: 12/01/12 最新の投稿
hi

instead of '$' try with 'jQuery' keyword. it may work
10年前 に anand gopalan によって更新されました。

RE: serveResource() is not calling

Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
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.
thumbnail
10年前 に Ravi GPR によって更新されました。

RE: serveResource() is not calling

Junior Member 投稿: 36 参加年月日: 12/01/12 最新の投稿
Hi,

Try this way it may work,

var url = "<%= yourResourceURL %>" + "&paramOne=" + paramOneValue + "&paramTwo=" + paramTwoValue;
jQuery.getJSON(url, function(data) {
// you can use your call back data
}
10年前 に anand gopalan によって更新されました。

RE: serveResource() is not calling

Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
Hi Ravi,


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);

});
});
}
});

}
thumbnail
10年前 に Ravi GPR によって更新されました。

RE: serveResource() is not calling

Junior Member 投稿: 36 参加年月日: 12/01/12 最新の投稿
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);
});
}
});
}
10年前 に anand gopalan によって更新されました。

RE: serveResource() is not calling

Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
than you so much Ravi, for your immediate response.
thumbnail
10年前 に Ravi GPR によって更新されました。

RE: serveResource() is not calling

Junior Member 投稿: 36 参加年月日: 12/01/12 最新の投稿
Is it work or not?
10年前 に anand gopalan によって更新されました。

RE: serveResource() is not calling

Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
sorry for delay reply its working, thank you Ravi
thumbnail
10年前 に Ketan Savaliya によって更新されました。

RE: serveResource() is not calling

Regular Member 投稿: 117 参加年月日: 11/03/03 最新の投稿
Hi,

This is same as bellow please look into that.
http://www.liferay.com/community/forums/-/message_boards/message/27265467

Thank you,
Ketan savaliya.
thumbnail
10年前 に Shankar Baba によって更新されました。

RE: serveResource() is not calling

Regular Member 投稿: 143 参加年月日: 12/10/18 最新の投稿
Thanks Ravi, it worked for me.