Wednesday, June 12, 2013

Vaadin - Ajax call - vaadin.forceSync()

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

Then, you can call vaadin.forceSync() to make a server request, which sends all pending variable changes (changes to client-side widgets) and syncs updates from server.

Reference:

http://stackoverflow.com/questions/13861103/vaadin-with-ajax
https://vaadin.com/forum/#!/thread/751447

Related Posts:

  • Eclipse - HTML Editor Plugin How to add an HTML Editor for Eclipse 1. Go to Help --> Install New Software...  2. Select the Juno repository (http://download.eclipse.org/releases/juno/) from the 'Work with:' menu: 3. In the se… Read More
  • Vaadin 7 - Ivyde - Eclipse Installing Vaadin Plugin for Eclipse If you are using the Eclipse IDE, using the Vaadin Plugin for Eclipse helps greatly. Notice that you can also create Vaadin projects as Maven projects in … Read More
  • Android - Failed to allocate memory - Application Error Is a directoryError Failed to allocate memory: 8 This application has requested the Runtime to terminate it in an unusual way. Solved:  Memory Options: change 1024 --> 512 Application Error Is a directory (file:///#androi… Read More
  • Vaadin - Activiti - Eclipse Eclipse IDE for Java EE Developers - Ganymede, Eclipse Indigo and Juno or newer Vaadin Plugin  To install the plugin: Select Install New Software... from the Help -menu Add new update site: Eclipse 3.5 an… Read More
  • Vaadin Touchkit - New Project Prerequisites: Eclipse Java EE IDE for Web Developers with m2eclipse plugin Apache Tomcat installed on your computer and integrated with Eclipse Sun Java 2 Standard Edition 6.0 (Java 1.5 or newer is required) 1. Cr… Read More

0 comments:

Post a Comment