Return mac address from an applet command

I am trying to retrive to vaadin app the client Mac Address via Applet Integration.

I already call doExecute(String command, Object params) successfully…

Now i have to pass the applet function result - getMacAddresses() - to Vaadin Application.

Checking the source of Screenshot addon i see Httpclient/PostMethod usage to pass the image stream to server.

But, on my case, i just want to return a simple string. Should i use the httpclient/postmethod too?.. or there is a simple way?

thanks in advance.

Currently posting directly from the applet to server is the easiest way. Check the
Screenshot add-on
code for details.

doPostToServer() method in the
sending a (multipart image data in this case). Especially you need to take care of the HTTP session cookie and correct parameter name.

You should also override the
method on to receive any custom variables. Note that the Screenshot component mentioned above extend the default Upload implementation and therefore no server-side receiver code is needed in that case.

Hi Sami,

i’m triying to receive my custom variables sent from an Applet, as you describe by using a similar function to doPostToServer() method:

PostMethod post = new PostMethod(postUrl);
					post.setRequestHeader("Cookie", sessionCookie);

					int i = 0;
					for (RemoteDevice rm : devicesDiscovered) {
						debug("p"+String.valueOf(i) + "-" + rm.getBluetoothAddress() +"-"+ rm.getFriendlyName(false));
						post.addParameter("p"+String.valueOf(i++), rm.getBluetoothAddress());

					HttpClient client = new HttpClient();
					int status = client.executeMethod(post);
					debug("status" + status);

Im getting this debug info from my applet:

debug: Post to server: http://localhost:8080//farmabide/
debug: p0-0023F1E6EBC7-W350i
debug: p1-001D25AC8226-newuni
debug: org.apache.commons.httpclient.methods.PostMethod@9945ce
debug: status 200

Im getting this parameters in my Application class by implementing HttpServletRequestListener:

[Start of request
 Query string: null
 Path: /
p1 = 001D25AC8226
p0 = 0023F1E6EBC7

Im inserting my applet with this code:

applet = new AppletIntegration() {

            private static final long serialVersionUID = 1L;

            public void attach() {
                setAppletArchives(Arrays.asList(new String[] { "medisync-applet.jar" }));

        	public void changeVariables(Object source, Map variables) {
        		System.out.println("SincronizacionTab4.SincronizacionTab4(...).new AppletIntegration() {...}.changeVariables()");
        		// Let superclass read any common variables.
        		super.changeVariables(source, variables);
        		// Sets the currently selected color
        	    if (variables.containsKey("p1")) {
        	        final String newValue = (String)variables.get("p1");
        	        // Changing the property of the component will
        	        // trigger a ValueChangeEvent
        	    if (variables.containsKey("p2")) {
        	        final String newValue = (String)variables.get("p2");
        	        // Changing the property of the component will
        	        // trigger a ValueChangeEvent

The problem is that
is not executing.

Any idea?

Thanks in advance,

If I didn’t miss anything important: The parameter naming.

Vaadin uses it internal scheme for http post parameter names. Typically they are format:
Here the is something that is matched to the variable name in changeVariables and is internally managed (currently like ‘PID’ and a number). I did this in the
applet implementation and there the POST parameter is something like ‘PID4_file’.

In the
AppletIntegration add-on
this is automatically handled and if inherit the AbstractVaadinApplet there is function getPaintableId that you can use to obtain the first part of the post parameter. For the latter part you can use whatever name you like (the server-side code with ‘p1’ and ‘p2’ is quite ok).

I just added in my Applet class getPaintableId()+“p1” but changeVariables is still not executing. Now i’m getting
on server:


I’ve also tried overriding paintContent method in my AppletIntegration class:

    public void paintContent(PaintTarget target) throws PaintException {
		target.addVariable(this, "p1", "---");


I’ve opted for retrieving parameter value in
method and manually updating server side component.

String p1= request.getParameter("p1");
if(p1!=null && !"".equals(p1)){

Anyway, thank you very much.


You have a valid workaround there. But this still bothers me so I checked this further. It seems that in my case (the screenshot) the multipart post request is handled differently by the framework and that is why it does not work for you.

Admittedly it is not good to mess with the internal protocol like this, and I think that I’ll add the function to AppletIntegration add-on directly to update a variable to server-side. That would be the right way to solve this.

Hi! Why source of screenshot addon isn’t full?