Girimurugan
Girimurugan

Reputation: 75

vaadin with ajax

Can any one help me How to send Portletrequest to vaadin from javascript as a AJAX call?

I have a requirement to display the selected value from javaScript in vaadin portlet popup window

I'm Using AJAX call to get the selected value .

But Ajax sends HTTP request so my portlet context is vanished .

Can any one help me how to portletrequest

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

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


}

Upvotes: 1

Views: 2369

Answers (1)

Girimurugan
Girimurugan

Reputation: 75

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

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

Upvotes: 1

Related Questions