Applet integration

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/

Hi everyone.
I’ve a little problem, my applet capture keyboard events correctly in windows OS, but not in linux.
I’m using chrome and firefox browsers on both OS.
I’ll test the “acsadam0404” solution if it fix it.
¿Some has the same problem?

Regards!

Hi I have a WebApp with Vaadin 7.0.7 and I want to Call an Applet for use a Token.

I did various tests:

  1. Use of AppletIntegration 1.2.9 but when I call applet there’s an Exception “ClassNotFoundException PaintTarget”
  2. Download Legacy 1.2.10 byhttps://github.com/Haulmont/AppletIntegration/releases but when I cal the page I have the Exception ""Widgetset does not contain implementation for org.vaadin.applet.AppletIntegration. 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.applet.AppletIntegration(NO CLIENT IMPLEMENTATION FOUND)"
3) I create a class AppletCustom

public class AppletCustom extends CustomComponent {
    public AppletCustom(String codebase, 
            String archive, 
            String code,
            String width, 
            String height,
            Map<String, String> params) {
        setCompositionRoot(new Label("<div id='appletDiv'></div>", ContentMode.HTML));
        StringBuilder sb = new StringBuilder();
                /* create the applet */
        sb.append("var obj = document.createElement('object');");
        sb.append("obj.setAttribute('type','application/x-java-applet');");
        sb.append("obj.setAttribute('width','" + width + "');");
        sb.append("obj.setAttribute('height','" + height + "');");        
        
        sb.append("var codeParam = document.createElement('param');");
        sb.append("codeParam.setAttribute('name', 'code');");
        sb.append("codeParam.setAttribute('value', '" + code + "');");
        sb.append("obj.appendChild(codeParam);");        
        
        sb.append("var archiveParam = document.createElement('param');");
        sb.append("archiveParam.setAttribute('name', 'archive');");
        sb.append("archiveParam.setAttribute('value','" + archive + "');");
        sb.append("obj.appendChild(archiveParam);");
         
        sb.append("var param = document.createElement('param');");
        sb.append("param.setAttribute('name', 'codebase');");
        sb.append("param.setAttribute('value','" + codebase + "');");
        sb.append("obj.appendChild(param);");
        
        /* add params to the applet if you like */
        if(params != null && !params.isEmpty()){
            Iterator<Entry<String, String>> it = 
                    params.entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry<String, String> pairs = (Map.Entry<String, String>) it.next();
                sb.append("param = document.createElement('param');");
                sb.append("param.setAttribute('name', '" + pairs.getKey() + "');");
                sb.append("param.setAttribute('value','" + pairs.getValue() + "');");
                sb.append("obj.appendChild(param);");
            }
        }        
        sb.append("document.getElementById('appletDiv').appendChild(obj);");
        JavaScript.getCurrent().execute(sb.toString());
    }
    
    
}

and I Call it in the page. The applet is seen correctly but i must to return a value using the method

vaadinUpdateVariable("docName", docName + SIGNED_FILE_SUFFIX, true);

Can You help me to resolve this problem?

Hi,

Recently we migrated to latest version of vaadin (7.4). From the time we move to latest version, the applet integrated inside the window is repainting more number of times (3-5times) and also on movement of the window from one location to another location, relaunching the applet. This is happening with IE 10 and not happening with chrome.

Did anyone faced similar kind of issue and any resolution or work around found to fix it?

Following are the ways tried,

a) Overriding the paintContent method of AppletIntegration
b) Verified that the component are causing refresh because of markAsDirty made for the controls and tried by disabling
c) Verified by passing the java arguments “-Dsun.java2d.noddraw=true”

But didnt worked out and not resolved the issue. Any suggestions are welcome.

Hi every one! If someone else is interesting, I found a solution for Out of Sync error in IE. By unknown reason, when applet removes from dom, IE instantiate new instance of applet, and if applet sends updateVariable on loading then Out of Sync is rasing, because on server side AppletIntegration component does not presence any more, and in server logs we can see warning message like: “Warning: Ignoring variable change for non-existent component, VAR_PID=PID76”.

To deal with this error, need override onDetach methon in VAppletIntegration and set html to empty string:

@Override
protected void onDetach() {
    setHTML("");
    super.onDetach();
}

Thanks Pavel for exploring towards this detachment.
I have implemented the code in VAppletIntegration class. However this has not resolved the issue of re instantiate applet on closure of the window. Any other alternative or suggestion.
it will be greatful, if you can share the applet integration jar you have made to resolve this issue,