ICEPush add-on

If you are reflecting changes from the data domain on your screen, several such changes can be happening at the same time. For example, if you have a table that represents a tournament scoreboard with mutliple matches, clearly there is the risk that several background threads would try to update the same application.

There is also the second risk that a user interaction (say, sorting the scoreboard by medals instead of countries) will happen from the Vaadin servlet at the same time your thread is attempting to play with the same objects.

I also had problem with the path.

I have my servlet mapped at ‘/register/*’ but the location given to Icepush ended up being ‘/’.
The wrong url is set in the init method in ICEPushServlet


37    javascriptProvider = new JavascriptProvider(getServletContext()
38                  .getContextPath());
39
40    ICEPush.setCodeJavascriptLocation(javascriptProvider
41                    .getCodeLocation());

If instead the icepush was not initialized before first request, then the servletpath would be available from the request object.
contextPath + servletPath should feed ICEPush the corect javascriptlocation.

/Michael

Hi all
can you explain how to use icepush in vaadin portlet an communicate betwen portlet clearly
i use IPC to communicate , it communicate sucess but view not update auto
please explain why thanks

Hi all
Perhap we use icepush in 2 portlet in different pages ,in different browser
i have a sceno 2 portlet communicate(send portlet,receiver portlet) ,i use IPC (jsr286), it send and receive data sucess ,and compile widgetset sucess,but reiceiver portlet not auto refresh
[b]
this is portlet send

[/b]
public class SenderEventApplication extends Application implements PortletListener{
Window window = new Window();

public void init() {
	

	setMainWindow(window);

	Label label = new Label("Hello Formbean!");

	window.addComponent(label);
	

	

	window.addComponent(label);
	Button button = new Button("Say Hi");
    button.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            // create an action URL and activate it to be able to create and
            // send an event
            if (getContext() instanceof PortletApplicationContext2) {
            	 PortletApplicationContext2 ctx = (PortletApplicationContext2) getContext();
               
                // set HelloState shared render parameter before sending the
                // event
                // note that this is inefficient as each call creates an
                // action
               
                [b]

ctx.sendPortletEvent(getMainWindow(), new QName(
http://www.test.com/test”, “hello”),
“hellow world”);
[/b]

            }
        }
    });
window.addComponent(button);

  

if(getContext() instanceof PortletApplicationContext2){
	PortletApplicationContext2 ctx=(PortletApplicationContext2) getContext();
	
	ctx.addPortletListener(this, this);
}
}

public void handleRenderRequest(RenderRequest request,
		RenderResponse response, Window window) {
	 if (getContext() instanceof PortletApplicationContext2) {
    	 PortletApplicationContext2 ctx = (PortletApplicationContext2) getContext();
    	
	 }
	 
	
}

public void handleActionRequest(ActionRequest request,
		ActionResponse response, Window window) {
	
	
}

public void handleEventRequest(EventRequest request,
		EventResponse response, Window window) {
	
			
			  
			 
		  }
	
}

public void handleResourceRequest(ResourceRequest request,
		ResourceResponse response, Window window) {
	
}

}


this is portlet receiver

public class ReceiverEvent extends Application implements PortletListener,PortletRequestListener{
Window window = new Window(“Vaadin Portlet Application”);
ICEPush icepush=new ICEPush();
PortletApplicationContext2 ctx ;
HorizontalLayout hr=new HorizontalLayout();

public void init() {
  
    setMainWindow(window);

    if (getContext() instanceof PortletApplicationContext2) {

ctx = (PortletApplicationContext2) getContext();
ctx.addPortletListener(this, this);}

        else {
       throw new RuntimeException("Only servlet deployment is supported");
       }
    hr.addComponent(icepush);
    window.addComponent(hr);
    
        
    }

    
   


public void handleRenderRequest(RenderRequest request,
		RenderResponse response, Window window) {
	System.out.println("--------------"+request.getPublicParameterMap().size());
	
}

public void handleActionRequest(ActionRequest request,
		ActionResponse response, Window window) {
	
}

public void handleEventRequest(EventRequest request,
		EventResponse response, Window window) {
	System.out.println("--------------"+request.getPublicParameterMap().size());
	 System.out.println(request.getParameter("hihi"));
	
	  if (request.getEvent().getName().equals("hello")) {
		
		
		  Label l=new Label request.getEvent().getValue().toString);
		  hr.addComponent(l);
		  icepush.push();
		
		  
		
		  
		 
	  }
	 
	
}

public void handleResourceRequest(ResourceRequest request,
		ResourceResponse response, Window window) {
	
	
}

public void onRequestStart(PortletRequest request, PortletResponse response) {

	
}

public void onRequestEnd(PortletRequest request, PortletResponse response) {

	
}


	
}

thanks for suggestion

I had to rewrite the servlet to do this:


/*
 * Copyright (C) 2011 Emergency CallWorx, Inc. All rights reserved.
 *
 * $Id$
 */

package com.clj2.web.lib.controller;

import com.vaadin.terminal.gwt.server.ApplicationServlet;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.icepush.servlet.MainServlet;
import org.vaadin.artur.icepush.ICEPush;
import org.vaadin.artur.icepush.JavascriptProvider;

public class ECXICEPushServlet extends ApplicationServlet {

    private MainServlet ICEPushServlet;
    private JavascriptProvider javascriptProvider;

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        try {
            super.init(servletConfig);
        } catch (ServletException e) {
            if (e.getMessage().equals("Application not specified in servlet parameters")) {
                // Ignore if application is not specified to allow the same
                // servlet to be used for only push in portals
            } else {
                throw e;
            }
        }

        this.ICEPushServlet = new MainServlet(servletConfig.getServletContext());

        try {
            String codeBasePath = servletConfig.getServletContext().getContextPath();
            String codeLocation = servletConfig.getInitParameter("codeBasePath");
            if (codeLocation != null)
                codeBasePath = codeLocation;
            if (codeBasePath.endsWith("/"))
                codeBasePath = codeBasePath.substring(0, codeBasePath.length() - 2);
            this.javascriptProvider = new JavascriptProvider(codeBasePath);
            ICEPush.setCodeJavascriptLocation(this.javascriptProvider.getCodeLocation());
        } catch (IOException e) {
            throw new ServletException("Error initializing JavascriptProvider", e);
        }
    }

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String pathInfo = request.getPathInfo();
        if (pathInfo != null && pathInfo.equals("/" + this.javascriptProvider.getCodeName())) {
            // Serve icepush.js
            serveIcePushCode(response);
            return;
        }

        if (request.getRequestURI().endsWith(".icepush")) {
            // Push request
            try {
                this.ICEPushServlet.service(request, response);
            } catch (ServletException e) {
                throw e;
            } catch (IOException e) {
                throw e;
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        } else {
            // Vaadin request
            super.service(request, response);
        }
    }

    private void serveIcePushCode(HttpServletResponse response) throws IOException {
        String icepushJavscript = this.javascriptProvider.getJavaScript();
        response.setHeader("Content-Type", "text/javascript");
        response.getOutputStream().write(icepushJavscript.getBytes());
    }

    @Override
    public void destroy() {
        super.destroy();
        this.ICEPushServlet.shutdown();
    }
}

you’d just add an init-param named codeBasePath with the value of the servlet mapping (e.g. /foo)

I’m writing a new app for which I’d like to use Navigator7 and ICEPush… I know that it’s possible to factor the app into several sub-contexts so that the main app can use Navigator, and the features can use ICEPush in, e.g. iframes. But this creates a cumbersome session management challenge. I’m curious to know whether anyone has made an effort in the direction of merging the Navigator and ICEPush code into a single servlet, or get any expert feedback on whether this is something a Vaadin newbie like myself would want to try doing.
Best regards,
Elliott

We know this (combining extensions to servlets) should be easier, but finding the right way to make it easier (and not breaking backwards compatibility) is far from trivial.

In your case, the easiest option is probably to inherit the servlet from Navigator and copy the few lines from ICEPushServlet to your servlet class.

I tried your servlet, Mark and it didn’t work for me until I made one tiny tweak:

changed:

codeBasePath = codeLocation;

to:

codeBasePath += codeLocation;

Then, it works great…thanks!

This addon would be exactly what I need but unfortunately I can’t get it working. I have problem with widgetset.

Unrendered UIDL
org.vaadin.artur.icepush.ICEPush(NO CLIENT IMPLEMENTATION FOUND) id=PID2 pushGroup=ICEPush-1 codeLocation=/krok/code.icepush

My project is maven project and I downloaded and added all 3 ICEPush jars into dependencies, one from Vaadin addon page and then two missing jars I installed into my local repository (which in my opinion really fights against easy adding of vaadin addons). When building project I get following text, I notice it says ERROR even I don’t see any error there and build works correctly.

[INFO]
— vaadin-maven-plugin:1.0.2:update-widgetset (default) @ vaadin —
[INFO]
auto discovered modules [fi.oodi.krok.ui.vaadin.widgetset.Ui_vaadinWidgetset]

[INFO]
Updating widgetset fi.oodi.krok.ui.vaadin.widgetset.Ui_vaadinWidgetset
[ERROR]
28.3.2012 11:10:14 com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
[ERROR]
INFO: Widgetsets found from classpath:
[ERROR]
com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:/home/jarik/.m2/repository/com/vaadin/vaadin/6.7.4/vaadin-6.7.4.jar!/
[ERROR]
org.vaadin.teemu.wizards.WizardsforvaadinWidgetset in jar:file:/home/jarik/.m2/repository/org/vaadin/addons/wizards-for-vaadin/0.4.1/wizards-for-vaadin-0.4.1.jar!/
[ERROR]
org.vaadin.artur.icepush.IcepushaddonWidgetset in jar:file:/home/jarik/.m2/repository/org/vaadin/addons/icepush/0.2.1/icepush-0.2.1.jar!/
[ERROR]
fi.oodi.krok.ui.vaadin.widgetset.Ui_vaadinWidgetset in file:/home/jarik/workspace/KROK/ui.vaadin/src/main/resources
[ERROR]
org.vaadin.overlay.OverlaysWidgetset in jar:file:/home/jarik/.m2/repository/org/vaadin/addons/overlays/0.9.8/overlays-0.9.8.jar!/
[ERROR]

[ERROR]
28.3.2012 11:10:14 com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
[ERROR]
INFO: Search took 18ms

I first had problem runnin mvn gwt:clean gwt:compile but that was fixed after I changed gwt-user version to 2.4.0. My vaadin version is 6.7.4.

I am using also Guice so my web.xml is different than in addon page, but my servlet class extends ICEPushServlet.

I just can’t get it working… :frowning:

I would still suspect that your web.xml does not refer to the widgetset correctly. Try to add “?debug” to the application URL and see what it says about the widgetset, or otherwise check which widgetset is loaded.

Also, check the rest of the widgetset compilation output to see that it is actually compiling and not skipping the ICEPush widget - the JAR is found during widgetset compilation, but maybe the widget in it is not included in the compilation.

The “ERROR” output is not really errors but high-priority output from an external utility that Maven shows as errors.

I would recommend using GWT 2.3 with Vaadin 6.7 if possible. GWT 2.4 seems to mostly work with the latest 6.7.x builds, but there are some minor issues.

I’m adding the ICEPush plugin to an existing project but I keep getting this error “java.lang.RuntimeException: Must be attached to an application to push” when I call “push()”.

I’ve read several other post of people having similar issues and for the most part the solution seems to be to make sure the pusher instance has been add to the mainWindow. However even though I’ve added the pusher instance to the mainWindow I always get the same error message. My guess is that its some how getting detached before I can use it in the application.

Here’s two code snippets. I first load a Login component and then after the user authenticates I remove the login component and add the Main window component.


        private ICEPush	m_icePusher;

	public void init()
	{
		s_CURRENT_APPLICTION.set(this); // So that we immediately have access to the current application

		Window mainWindow = new Window("Device Manager Web Application");
		setTheme("DeviceManager");

		setMainWindow(mainWindow);

		// Add the push component
		m_icePusher = new ICEPush();
                mainWindow.addComponent(m_icePusher);

		getMainWindow().setContent(new Login());
	}

    public boolean authentication(String p_username, String p_password)
	{
		boolean t_status = false;
		UserInfo t_user = new UserInfo();
		t_user.setUsername(p_username);
		t_user.setPassword(p_password);

		AuthResponse t_aResponse = DEVICE_MANAGER_API.authenticate(t_user);

		if (t_aResponse.getAuthToken() != null && t_aResponse.getUserID() > 0)
		{
			getMainWindow().setContent(null);
			getMainWindow().setContent(new Main());

			t_status = true;
		}

		return t_status;
	}

Note: I’ve also tried moving the add pusher instance into the authentication function but that doesn’t seems to make a different either.

Thanks for your help.

I’m past that problem now. Ultimately the problem was what I had guessed. Apparently getMainWindow().setContent() removes any previous layouts. I’m now using getMainWindow().addComponent / removeComponent to work around that issue.

However the problem I’m experiencing now is that the UI never updates until the background thread is stopped. Once the thread stops the console spews the following messages:
Mar 30, 2012 2:58:03 PM com.vaadin.terminal.gwt.server.AbstractCommunicationManager handleVariableBurst
WARNING: Warning: Ignoring variable change for non-existent component, VAR_PID=PID2
Mar 30, 2012 2:58:03 PM com.vaadin.terminal.gwt.server.AbstractCommunicationManager handleVariableBurst
WARNING: Warning: Ignoring variable change for non-existent component, VAR_PID=PID2
Mar 30, 2012 2:58:03 PM com.vaadin.terminal.gwt.server.AbstractCommunicationManager handleVariableBurst
WARNING: Warning: Ignoring variable change for non-existent component, VAR_PID=PID2
Mar 30, 2012 2:58:03 PM com.vaadin.terminal.gwt.server.AbstractCommunicationManager handleVariableBurst

Presumably I’m getting 2 lines for every time push() was called. After all those messages finish writing to the console the UI window updates showing the last update in the window.

Why is my window not getting updated every time I call push()?

The previously mentioned issue has also now gone away.

WARNING: Warning: Ignoring variable change for non-existent component, VAR_PID=PID2
Mar 30, 2012 2:58:03 PM com.vaadin.terminal.gwt.server.AbstractCommunicationManager handleVariableBurst

I’m no longer getting these warning messages (with no real reason why they’ve gone away) however I’m still having the same issue that the ui only updates once the background thread stops.

Below is my run function in the background thread.


private Embedded	m_videoImage = new Embedded();

public void run()
	{
		// Get the proxy IP/Port from ConfigManager from either the edm.* or deviceManager.*
		ProxyConnectionInfo proxyDetails = new ProxyConnectionInfo();

		String t_proxyIP = null;
		int t_proxyPort = 0;

		if (ConfigManager.GetValue("edm.proxyLocalIP") != null)
		{
			t_proxyIP = ConfigManager.GetValue("edm.proxyLocalIP");
			t_proxyPort = ConfigManager.GetIntValue("edm.proxyPort");
		}
		else
		{
			Logger.LogInfo("EDM configuration values are not present.");

			t_proxyIP = ConfigManager.GetValue("deviceManager.proxyIPAddress");
			t_proxyPort = ConfigManager.GetIntValue("deviceManager.proxyPort");
		}

		proxyDetails.setIPAddress(t_proxyIP);
		proxyDetails.setPort(t_proxyPort);

		// Step #1: Connect to Proxy Server
		Logger.LogInfo("Step #1: Establish connection to Proxy.");

		ConnectionManager p_proxyConn = new ConnectionManager(m_device, proxyDetails, null);

		// test for connection failure
		if (p_proxyConn != null && p_proxyConn.isOpen())
		{
			int responseCode = -1;
			StringBuilder t_responseContent = new StringBuilder();

			try
			{
				byte[] t_imageStream = null;

				while (m_play)
				{
					responseCode = p_proxyConn.postAndWaitForReponse("uid=001&image1=" + ((ImageType) m_ddlImageType.getValue()).getStreamId(), "registerClient.cgi", m_device.getUserName(), m_device.getPassword(), t_responseContent);

					if (responseCode == HttpComm.HTTP_OK)
					{
						// Get the image stream
						Logger.LogDebug("Step #2: Get Video Stream Image");

						t_imageStream = p_proxyConn.getAndWaitForReponse("", ((ImageType) m_ddlImageType.getValue()).getFileName(), m_device.getUserName(), m_device.getPassword());

						if (t_imageStream != null && t_imageStream.length > 114)
						{
							Resource t_resource = utils.convertByteArrayToStream(t_imageStream);

							// Update UI
							synchronized (DeviceManagerWebApplication.getInstance())
							{
								m_videoImage.setSource(t_resource);
							}

							// Push the changes							
							DeviceManagerWebApplication.getInstance().getPushObject().push();
							Thread.sleep(500);
						}
						else
						{
							Logger.LogDebug("Return Length: " + t_imageStream.length);
						}
					}
					else
					{
						m_play = false;
					}
				}
			}
			catch (Exception ex)
			{
				Logger.LogError("VideoStream.run() | " + ex.toString());
				m_play = false;
			}
		}
		else
		{
			Logger.LogInfo("Step #1: Failed to Connect to Proxy: " + p_proxyConn.getProxyMessage());
			Logger.LogInfo("Step #2: Skipped Device IP: " + m_device.getIPAddress());
		}
	}

Let me know what I’m doing wrong.

If you happen to have updating issues with ICEPush, make sure you are not changing the container of ICEPush instance. We found out that relocating ICEPush under new layout/container will cause random problems when pushing (update not happening). Workaround for this is to add top level layout to window that is not replaced with another. Add ICEPush instance to this top level layout, and keep it there.

Hi.
I can not get the ICEPush working.
Here is part of my web.xml:

<servlet>
		<servlet-name>dispatcher-servlet</servlet-name>
		<servlet-class>com.myapp.web.DispatcherServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>dispatcher-servlet</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>

and my DispatcherServlet:

public class DispatcherServlet extends ICEPushServlet {
    public void service(HttpServletRequest req, HttpServletResponse res) {
        //some processing
        super.service(req, res);
   }

}

and, finally, my Application class

public class Application extends com.vaadin.Application {

    private ICEPush pusher = new ICEPush();

    private void setPusher() { //because I use setContent() method for main window
		Window window = getMainWindow();
		window.removeComponent(pusher);
		pusher.setParent(null);
		window.addComponent(pusher);
	}
	
	public void push() {
		setPusher();
		pusher.push();
	}
}

I want add new window to main window asynchronous (video chat call notification). I do it like this:

application.getMainWindow().addWindow(notificationWindow);
application.push();

Window does not appear. What am I doing wrong?

Hi,

I am using ICEPush with vaadin 7. I get this warning everytime i try to push

“com.vaadin.terminal.gwt.server.ServerRpcManager applyInvocation
WARNING: RPC call received for RpcTarget org.vaadin.artur.icepush.ICEPush (97) but the target has not registered any RPC interfaces”

Any help will be appreciated. :slight_smile:

Thanks

Hi!
I am testing Vaadin 7 rc2 with Spring integration - how to add the ICEPush servlet to web.xml? My primary servlet is a SpringIntegrationServlet… i try to create a second servlet ICEPushServlet in web.xml, but in application push method do not working and no errors.

Answered in another thread where you posted as I saw it before this one, even though this would be more correct.

Please do not post duplicates but only pick the most appropriate thread or a new thread.

Has anyone tried using ICEPush in a Vaadin app deployed on Glassfish running behind Apache using mod_proxy?

That’s the configuration that I’m trying to get working. The app all works correctly except for ICEPush not pushing.

ICEPush works fine when going direct to a Glassfish server, but when proxied with Apache I’m not seeing the “POST listen.icepush” although I do see the other three requests.

My VirtualHost config on Apache looks like

<VirtualHost>
    .
    .
    .
    ProxyPass / http://server:port/appcontext/
    ProxyPassReverse / http://server:port/appcontext/
    ProxyPassReverseCookiePath /appcontext /
</VirtualHost>

Can anyone help, I’ve tried a number of different variations of the proxypass config, but nothing I try seems to make any difference?

Any assistance would be much appreciated.

Alex

Hey Arthur, thanks for a great addon!

However, is this add-on in any way combinable with the Vaadin Touchkit?

Since they are both replacing the servlet… I just realized this after developing an entire mobile application using icepush, and while the push parts work flawlessly… the application will not behave as a webapp on the phone (or alternatively the push won’t work, but the application behaves as a phone app). Feels like I just hit a wall…

Using Vaadin 6 at the moment, would upgrading to 7 solve my problem, or will I still run into the same issue with two different servlet classes?