JavaScriptFunction fail with vaadin 7.4

Hi, all !!!
I use : vaadin 7.4, wildfly 8.1.0.final.
I`m spended 2 days yet to find woraround of problem : @How to read / write cookie with enabled @Push but still in dead end.

  1. I had VaadinService.getCurrentRequest().getCookies() works correctly until i enable @Push. Ok, i read that its good workaround use JS to do this instead.
  2. Try to use JS:
    a) Define method to init JS callback:
    private void createJavaScriptCallbackForReadingCookie()
    {
    Page.getCurrent().getJavaScript()
    .addFunction(“cookieCallback”, new JavaScriptFunction() {
    @Override
    public void call(JSONArray arguments) throws JSONException
    {
    System.out.println(arguments);
    }
    }); }
    b) call it as first stroke in init(VaadinRequest request) method to initialize him.
    c) second stroke try to call it :
    Page.getCurrent().getJavaScript().execute(“cookieCallback(document.cookie)”);
    e) see in chrome console and see :
    INFO: Making UIDL Request with params: {“csrfToken”:“3df9ff7b-ecd9-4b91-aee9-0f8632f95b36”,“rpc”:[[“1”,“com.vaadin.ui.JavaScript$JavaScriptCallbackRpc”,“call”,[“cookieCallback”,["RepairDepotUserLogin=test@test.com; JSESSIONID=8cbBCQRlg-I0a1Zc5rlajAeU.mul]
    ]]],“syncId”:1}
    d) see in application log see :


    Please help to fix problem, or advise something ? How i can do cookies works with @Push enabled ?

JavaScriptFunction has changed its implementation. now vaadin using
elemental.json.JsonArray instead of previous org.json.JSONArray.

this may break implentation of JavaScriptFunction. IMO bad descition to make. use as below.

private void createJavaScriptCallbackForReadingCookie()
    {
        Page.getCurrent().getJavaScript()
                .addFunction("cookieCallback", new JavaScriptFunction() {
                    @Override
                     public void call(JsonArray jsonArray) {
                       System.out.println(arguments);
                     }      
                    }
                });  }

Very thanks for reply, Sameera !

I think you are quite right !
https://vaadin.com/api/com/vaadin/ui/JavaScriptFunction.html
In API this function is really works with elemental.json.JsonArray, but its seems a dont have enought experience to understand, how to resolve this problem.

I use maven as dependency management tool, and as i said in my first post it flow me with vaadin-server-7.3.3.jar

Then when i try to use JavaScriptFunction eclipse offer me only method with org.json.JSONArray parameter.

Maybe its a bug ?! But i have only such interface for JavaScriptFunction and it doesnt work. =(

Can you explain how i can shuffle that interface in my class path ?

use latest vaadin version

I check my Libraries package and define root problem.

It`s all my experiments of compiling widgetset … I have vaadin-server-7.3.3.jar that i added manually for tests and forgot to delete. And now this jar overflow maven last version dependencies.

Deleting that jars resolve my problem and JavaScript callback work fine now with elemental.json.JsonArray as expected !

Very thanks for you, Sameer !!! =)

great :slight_smile: