Applet integration

Also, AppletIntegration class is not compatible w/ a portal since on line 97 (of 1.2.9) you expect that the context is a WebApplicationContext; in the portal this would be a PortletApplicationContext2 instance.

I changed line 97 to read:

ApplicationContext appCtx = app.getContext();

if (appCtx != null) {
  if (appCtx instanceof WebApplicationContext) {
    WebApplicationContext ctx = (WebApplicationContext) appCtx;
    return ctx.getHttpSession().getId();
  }
  if (appCtx instanceof PortletApplicationContext2) {
    PortletApplicationContext2 ctx = (PortletApplicationContext2) appCtx;
    return ctx.getPortletSession().getId();
  }
}

And this seems to work just fine. Please incorporate this into your next release…

Hi :grin:

I’m working on the project where I need your component again :slight_smile:

While I was testing application I saw that in Google Chrome user must click two times on button to call execute method of the applet. I thought the problem is with my implementation, so I visited http://sami.virtuallypreinstalled.com/screenshot to see how does it work. Same thing there. In debug console we get:

Applet command: v-appletPID11,‘screenshot’,‘null’

JavaScriptException: (TypeError): Object [object HTMLAppletElement]
has no method ‘execute’

Processing time was 62ms for 778 characters of JSON

After bit of analyzing I figured out that error pops out because javascript is calling applet before it has been loaded (?). Because of that I added few lines of code to be sure that applet is loaded before calling execute method. Here is the code:

VAppletIntegration:

added methods

private native static boolean isAppletLoaded()/*-{
		return $wnd.vaadin.isAppletLoaded();
	}-*/;
	
	private native static void exportJSFunctionsForAppletStatistics()/*-{
	var appletLoaded = false;
		$wnd.vaadin.setAppletLoaded = function(loaded){
			appletLoaded = loaded;
		}
		$wnd.vaadin.isAppletLoaded = function(){
			return appletLoaded;
		}
	}-*/;

I also modified updateFromUIDL(UIDL uidl, ApplicationConnection client) method.


...
if (!appletInitialized) {
			exportJSFunctionsForAppletStatistics(); //added this line
			// Applet class
			if (!uidl.hasAttribute(ATTR_APPLET_CLASS)) {
				VConsole.log("Missing attribute " + ATTR_APPLET_CLASS);
				return;
			}
			appletClass=....

At the end of this method I added lines:


...
if (cmd != null) {
				timer=new Timer() {
					@Override
					public void run() {
						if (isAppletLoaded()) {
							VConsole.log("Command: "+cmd);
							execute(cmd, cmdParams);
							cancel();
						}
					}
				};
				VConsole.log("Waiting for applet to load!!!");
				timer.scheduleRepeating(100);
		}

AbstractVaadinApplet:


  public void setAppletLoaded(){
    	String cmd = "vaadin.setAppletLoaded(true)";
    	jsCall(cmd);
    }

Now in my applet as last line of the init() method i put setAppletLoaded()

Basically the applet informs client side that he is ready. This works fine, but if there is a better solution I would like to use it.

Regards :slight_smile:

Veselin

Hi guys,

i’m new to java and vaadin, and i need to use an applet on my next project.
i have been tryin for a few days but i’m still unabled to acomplish the result.

i’m able to use the screenshot demo, but i cant do it with my own applet, a simple applet to show a message as test.

if someone could help me i’ll appreciated, explain me what to do or show me some simple example, because a think the screenshot example like a complex one.

Thank you,
Paulo David

PS:Sorry for my english, i hope you can understand what i’m tryin to do. :slight_smile:

Someone please…

i’m became desperate…

Thank you,
Paulo David

Hi,

This sound like you have packaging / build issue.

Sure. Using a applet is another thing than packaging it the right way. There are some steps that you have to do carefully in certain order to make everything to work. As a reference take a look at the sample build script for an applet.

For starters, access your web applicaton with a browser and see on JavaScript/Java log that everything is loaded correctly. If not, that should give us some indication what might be wrong:
dev.vaadin.com/svn/contrib/Screenshot/sample-build.xml

Hi!

I’m want to put some xml data to my applet:

 setAppletParams("requestBodyXML", requestBodyXML);

But with this code on applet side I get:

String requestBodyXML = getParameter("requestBodyXML");
System.out.println("requestServiceXML: " + requestBodyXML);

requestServiceXML: <?xml version=

Why parameter cut on <"> charster?
I’m try to do with

 requestBodyXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

No effect. Applet get only ‘<?xml version=’ value…
Why my param truncate?

Thank You!

update:
this is common applet parameters issue
http://stackoverflow.com/questions/6546779/what-kind-of-escaping-for-java-applet-parameters

Just a little question about applet and vaadin servlet communication. I made allmost identical uploading class than example screenshot.java - but when I sent uploaded file into vaadin servlet it failing down and applet got 500.
I am working with ibm Websphere. Everything else work 100% except upload.
This was just sort explanation, but have you anything idea to where start looking the reason that servlet failing about message.

Can we expect version 7 compatibility any time soon for this add-on?

Thank you very much. After a week hitting a wall, your post has solved my problems.

I vote for that, too.

Hi everyone,

I need help with my Applet Integration, in a few words it should fill a hash with ids every time I check a CheckBox. When I test it in raw HTML it works fine, but I need it to run in Vaadin which isn’t working.

Applet Function: public void set(String compId,String url,String empresa,String valorInternet, String valorNormal,String destValorInternet,String destValorNormal){ String[] dat={url,empresa,valorInternet,valorNormal,destValorInternet,destValorNormal}; this.hash.put(compId, dat); }
Applet Invocation:[code]
AppletIntegration() appletActualizacion = new AppletIntegration(){
private static final long serialVersionUID = 1L;
@Override
public void attach() {
setAppletArchives(Arrays.asList(new String { “AppletActualizador.jar” }));
setCodebase(“VAADIN/applets/”);
setAppletClass(“applet.ActualizadorForm”);
setWidth(“180px”);
setHeight(“30px”);
}
};

if ((Boolean) cb_selected.getValue()){
appletActualizacion.executeCommand(“set”, params);
}
[/code]

Whenever I check this Checkbox I get this error in the Debug Window:

Applet command: v-appletPID63,‘set’,‘[Ljava.lang.String;@f7
JavaScriptException: (TypeError): $doc.applets[b]
.execute is not a function stack: B0b@http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html:1717 H0b@http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html:3275 yW@http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html:3234 _U@http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html:3025 $V@http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html:3254 um@http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html:2465 Um@http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html:3251 d.onreadystatechange<@http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html:1767 Rb@http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html:1389 Ub@http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html:2715 @http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html:1928 fileName: http://localhost:8080/tiendas_online/VAADIN/widgetsets/com.tiendas_online.widgetset.Tiendas_onlineWidgetset/5D521CAC808A83B1CFB8545E25C3B747.cache.html lineNumber: 1717 columnNumber: 20

I hope you can help me, thanks

Can we expect version 7 compatibility any time soon for this add-on?

Hello,

we’ve created and added an applet in our application using the Applet Integreation addon (v1.2.9) and Vaadin v 6.8.4.
Our application consists of a menu and a different page that is displayed according to the selected menuitem.

One of these pages contains an applet:


public class InfoPage extends VerticalLayout {
		
	public InfoPage() {
		super();
		
		this.addComponent(new Label("Information screen"));
		
		final AppletIntegration applet = new AppletIntegration() {
			
			@Override
			public void attach() {
				this.setAppletArchives(new String[] { "testapplet.jar", "appletintegration.jar" });
				this.setCodebase("applet/testcodebase/");
				this.setAppletClass("test/TestApplet");
				this.setWidth("300px");
				this.setHeight("300px");
			}
			
		};
		this.addComponent(applet);
		
                // ...
	}
}

The applet:


public class TestApplet extends AbstractVaadinApplet {
		
	@Override
	public void init() {
		super.init();
		System.out.println("Initializing TestApplet");
		//...
	}
	
	@Override
	protected void doExecute(final String command, final Object[] params) {
		System.out.println("Executing: " + command);
	}
	
}

Everthing works fine, when the page is loaded, the applet is added and initialized correctly (tested in FF, Google Chrome and IE).
When we select another menuitem, this page is destroyed (incl applet teardown) and another page is loaded.
In IE (tested in 6-7-8-9) for some reason the applet is ‘restarted’ as the message we print in init() is printed again in the java console. This doesn’t happen in Google Chrome and FF. This behaviour is a bit annoying for us as the init is executed unnecessarily during the ‘restart’. I’ve been looking around why this happens, but I can’t find a reason or solution for it. Does anybody knows why IE restarts the applet and how we can avoid this behaviour?

Thank you.

Sami –

I understand that integration of client-side java is not a priority for a server-side java framework, but this project really serves a need for some of us. Is there any chance to get this moved to Vaadin 7 soon? Is there somewhere I could vote for that?

– Sean

Vaadin 7 compatible any soon?

The author or the add-on is on a long summer vacation, so I would not expect any reply soon.
For this add-on, a full rewrite might be the best way to migrate it for Vaadin 7 as it could use many of the new features of Vaadin 7.

Hi Alexander!
I know it’s long ago, but currently I’m facing the same “Requested resource not found from filesystem or through class loader” -problem.

Would you be so kind and explain to me how you solved this issue, please?

Thanks!

hi

I am using this add-on but the one ported to vaadin 7 by
https://github.com/Haulmont/AppletIntegration

I did the exact thing you suggested but I am getting this error when trying to send variable to server :

Oct 30, 2013 10:23:33 PM com.vaadin.server.communication.ServerRpcHandler parseInvocation
WARNING: RPC call to v.v received for connector 9 but no such connector could be found. Resynchronizing client.

Do you have any idea, what could be the problem? I dont know what I am doing wrong.
Thanks in advance.

Hi Gokhan, I made it work receiving variables updates by adding super.attach() in the attach method. I was delaying Vaadin 7 because of this addon, now it seems I can move on…

appletCodigos = new AppletIntegration() {

            @Override
            public void attach() {
                // must be added
                super.attach();
                
                setAppletArchives(Arrays.asList(new String[] { "appletCodigos.jar,appletintegration-1.2.10.jar" }));
                setCodebase("VAADIN/");
                setAppletClass("ImprimirCodigos.class");
                setWidth("0px");
                setHeight("0px");

                /*
                 * Send parameters to the applet
                 */                
                setAppletParams("myParameters","values");                                                    
            }

            @Override
            public void changeVariables(Object source, Map variables) {
                super.changeVariables(source, variables);
                
                /*
                 * Recieve variables updates
                 */            
                
                if (variables.containsKey("estadoOk")) {                    
                    String strEstadoOk = (String) variables.get("estadoOk");            
                    if (strEstadoOk.equals("false")){;
                        System.out.println("Error");                    
                    } else {
                        appletCodigos.executeCommand("exit");    
                    }
                }    
            }
        };        
        view.addComponent(appletCodigos);
        appletCodigos.executeCommand("imprimirCodigos");

Hi everyone.
What is the straightforward way to clean an old jar’s cache?
If i remove the jar that i did use in setAppletArchives, the project still working.

PS: Thanks Maximiliano, I had the Gokhan’s problem too.
Thanks in advance.
Best Regards!

Edit1: I did a little research.
Using find command i found 2 jars.
The path to the cached jar is
" /home/francisco/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/BotQueueWeb/VAADIN/applet/"
i.e. this is on eclipse’s catalina_base temporary folder to deploy.
Why update “everything”, except this jar? To avoid unnecessary work?

Just figured out I don’t need any addon to integrate an applet. Check out this blogspot if you ran into trouble with the addon: http://acsadam0404.blog.com/2014/05/02/simple_vaadin7_applet_integration/