Reputation: 4581
Asked on this Liferay Forum post
I am trying to make an AJAX request from my Lifery portlet utilizing <portlet:resourceURL>
.
index.jsp
<portlet:resourceURL var="search" id="recordId"></portlet:resourceURL>
<a href="#" onclick="ajaxCall('${search}')">CLICK ME</a>
<script>
var id = 100;
function ajaxCall(ajaxUrl){
$.ajax({
url : ajaxUrl,
data : {
id: id
},
type: 'GET',
dataType : "json",
success : function(data) {
// do stuff on success
},
error: function () {
//do stuff on error
console.log('Error Occurred');
}
});
}
</script>
And my @Controller
@Controller
@PropertySource("classpath:application.properties")
@RequestMapping(value = "VIEW")
public class SearchController {
@ActionMapping
public void handleActionRequest(ActionRequest request, ActionResponse response)throws Exception {
System.out.print("In the Action Mapping Handler");
return;
}
@RenderMapping
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response, ModelMap model) {
return new ModelAndView("index", model);
}
@ResourceMapping(value = "search")
@ResponseBody
public void getPlan(ResourceRequest request, ResourceResponse response) throws PortalException, SystemException, IOException {
System.out.println("In the search Controller");
}
}
However I am getting the error and am not sure why
org.springframework.web.portlet.NoHandlerFoundException: No handler found for portlet request: mode 'view', phase 'RESOURCE_PHASE', parameters map[[empty]]
The Request URL:
http://localhost:8090/portal/web/mySite/home?p_p_id=MyApp_WAR_MyApp&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=recordId&p_p_cacheability=cacheLevelPage&p_p_col_id=column-1&p_p_col_count=1&id=100
Any ideas?
Upvotes: 0
Views: 436
Reputation: 63
@ResourceMapping(value="recordId") would work as mentioned by Pankaj.
Upvotes: 1