1

I have to pass one Javascript object using JavascriptInterface. I've already lots of function which implements JavascriptInterface but I only pass String objects and I've never tried to pass a not-primitive one.

In my .jsp:

var trnsCfg = {}

trnsCfg['trn_enb'] = '1';

trnsCfg['lang'] = 'it_IT';

window.JSInterface.startTranslator(trnsCfg);

In my .java:


@JavascriptInterface

public void startTranslator(ObjectIWantToUse object){

    object.doSomethingWithIt();

    //something

};

In this example used ObjectIWantToUse but what I have pratically put? And how will I be able to use this Object properties (like 'trn_enb' or 'lang')?

4
  • You want to code a function in Javascript and then execute it in Java?? Or do you just want to access the object properties? Commented Apr 16, 2019 at 13:40
  • I want to access the object properties like a simple data structure Commented Apr 16, 2019 at 13:42
  • 1
    Try this... stackoverflow.com/questions/2250917/… Commented Apr 16, 2019 at 13:43
  • Ok, I'll try thank you Commented Apr 16, 2019 at 13:48

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.