vaadin与Ajax [英] vaadin with ajax
问题描述
有人可以帮助我如何通过AJAX调用将javascript的Portletrequest发送到vaadin吗?
Can any one help me How to send Portletrequest to vaadin from javascript as a AJAX call?
我需要在vaadin portlet弹出窗口中显示从javaScript中选择的值
I have a requirement to display the selected value from javaScript in vaadin portlet popup window
我正在使用AJAX调用来获取所选值.
I'm Using AJAX call to get the selected value .
但是Ajax发送HTTP请求,所以我的portlet上下文消失了.
But Ajax sends HTTP request so my portlet context is vanished .
任何人都可以帮助我如何进行portletrequest
Can any one help me how to portletrequest
我从JavaScript调用Ajax:
My Ajax Call from JavaScript:
$.ajax(
{
type : "POST",
url : "serveResource",
data : {"tBPMNObject": JSON.stringify(chart.series.name)},
dataType : "json"
}
).done(function(responseData)
{
console.log("Success#");
console.log(responseData);
}
).fail(function(responseData)
{
console.log("failed-->");
console.log(responseData);
});
通过实现HttpServletRequestListener在vaadin中进行请求
And the request in vaadin by implementing HttpServletRequestListener
public void onRequestStart(HttpServletRequest request,
HttpServletResponse response) {
String name = request.getParameter("tBPMNObject");
}
@Override
public void onRequestEnd(HttpServletRequest request,
HttpServletResponse response) {
}
推荐答案
我们可以通过在ajax中传递友好的URL,将请求发送到handelRenderRequest.
We can send the request to handelRenderRequest by passing the friendly url in the ajax
$.ajax(
{
type : "POST",
url :"Friendly URL of the portlet",
data : {"CHART_VALUE": JSON.stringify(chart.series.name)},
dataType : "json"
}
).done(function(responseData)
{
console.log("Success#");
console.log(responseData);
vaadin.forceSync();
}
).fail(function(responseData)
{
console.log("failed-->");
console.log(responseData);
vaadin.forceSync();
});
我们可以通过使用以下命令在renderrequest中获取值 request.getParameter("CHART_VALUE");
We can get the value in the renderrequest by using request.getParameter("CHART_VALUE");
private class LiferayPortletListener implements PortletListener
{
public void handleRenderRequest(RenderRequest request, RenderResponse response, Window window)
{
system.out.println(request.getParameter("CHART_VALUE"));
}}
这篇关于vaadin与Ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!