ICEPush add-on

Hi

When adding the ICEPush to my window I get a large blank space at the top of my browser screen.




		final VerticalLayout layout = new VerticalLayout();
		final Window mainWindow = new Window("Client", layout);
		setMainWindow(mainWindow);
		mainWindow.addComponent(icePush);
		mainWindow.setSizeFull();
		
		layout.setSizeFull();

Is there something else one should set?

Hi Artur;

Ive tried to use ice Push and it works like a charm.

But got also same problem if I don’t map application to an /* url.

I really need to map it into 2 context as my war is hosting ui application and ws application in two differents contexts like this
/app/* for IcepushServlet and /ws/* for a CXF Servlet.

I also use a custom Servlet as I’m using Navigator Add-on.

is there a way to configure the servlet in order it can handlle icepush query on a different path than the “match all” path ?

Thanks,

Anthony

I have the exact same requirement (…/app for webapp and …/m for Android/iPod). I had tried the newer version and had not had time to figure out why it did not work. So I had to revert to the prior version.

Same problem here! Reverted to version 0.1.2

Do you talk about 0.1.2 icepush lib or add-lib ?

I can’t find 0.1.2 version on the Vaadin Maven repo

I’ve no idea what was the lib or add-lib. I’m using maven to manage the dependencies.

<dependency>
   <groupId>org.vaadin.addons</groupId>
   <artifactId>icepush</artifactId>
   <version>0.1.2</version>
</dependency>

<repository>
   <id>vaadin-addons</id>
   <url>http://maven.vaadin.com/vaadin-addons</url>
</repository>

You can switch between versions by clicking the version number at the page

http://vaadin.com/directory#addon/icepush
11580.png

Hi, I have the same problem (first screenshot):


	....

	@Override
	public void init()
	{
		mainWindow = new Window(caption);
		mainWindow.setSizeFull();

		// this line leads to the problem, but it is necessary!
		mainWindow.getContent().setSizeFull();

		setMainWindow(mainWindow);
		mainWindow.addComponent(pusher);
		
		...

The following code solves the problem partially, but the height is still wrong (second screenshot):


	@Override
	public void init()
	{
		mainWindow = new Window(caption);
		mainWindow.setSizeFull();
		VerticalLayout content = new VerticalLayout();
		mainWindow.setContent(content);
		mainWindow.getContent().setSizeFull();
		setMainWindow(mainWindow);

		content.addComponent(pusher);
		content.setExpandRatio(pusher, 0f);

11659.png
11660.png

Problem solved:


	@Override
	public void init()
	{
		mainWindow = new Window(caption);
		mainWindow.setSizeFull();
		VerticalLayout content = new VerticalLayout();
		mainWindow.setContent(content);
		mainWindow.getContent().setSizeFull();
		setMainWindow(mainWindow);

		mainWindow.addComponent(pusher);
		content.setExpandRatio(pusher, 0f);

		mainLayout = new VerticalLayout();
		mainWindow.addComponent(mainLayout );
		content.setExpandRatio(mainLayout, 1f);

Hi

I’m getting problems with this plugin. I get this in the screen

Widgetset does not contain implementation for org.vaadin.artur.icepush.ICEPush. Check its @ClientWidget mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions. Unrendered UIDL:

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

Remaining components are shown OK.

First I was using Vaadin 6.6.0, gwt 2.3.0 and latest gwt-maven plugin. Then I downgraded to Vaadin 6.5.7, but the error is the same. icepush-0.2.1, icepush-gwt and icepush are in WEB-INF/lib

Any ideas?

Thanks
Aniceto

Hi

Sample code updates UI in a synchronized block. What i not thread safe? The window object, every ui object or any ui update even if they are done to different objects?

Thanks

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.