jsni

How to pass javascript object to GWT method and parse result

て烟熏妆下的殇ゞ 提交于 2020-06-12 08:53:16
问题 I have this GWT method: public static native JavaScriptObject getJsValue() /*-{ var res = $wnd.product; return res; }-*/; This is the HTML/JS part: <script type="text/javascript" language="javascript"> var product = products({id:1}).first(); </script> <!-- GWT --> <script type="text/javascript" language="javascript" src="app/app.nocache.js"></script> The object product looks like this in Firebug: Object { id=1, categoryid=0, name="Sample Product", more...} After then, Object obj = getJsValue(

Firestore web code sample gives invalid argument type

若如初见. 提交于 2020-02-21 06:31:27
问题 I am trying out the new Firestore by Firebase. When I run the code sample from https://firebase.google.com/docs/firestore/manage-data/add-data?authuser=0, I am getting an error. // Add a new document with a generated id. db.collection("cities").add({ name: "Tokyo", country: "Japan" }) .then(function(docRef) { console.log("Document written with ID: ", docRef.id); }) .catch(function(error) { console.error("Error adding document: ", error); }); Exception caught: (FirebaseError) : Function

Firestore web code sample gives invalid argument type

痞子三分冷 提交于 2020-02-21 06:31:26
问题 I am trying out the new Firestore by Firebase. When I run the code sample from https://firebase.google.com/docs/firestore/manage-data/add-data?authuser=0, I am getting an error. // Add a new document with a generated id. db.collection("cities").add({ name: "Tokyo", country: "Japan" }) .then(function(docRef) { console.log("Document written with ID: ", docRef.id); }) .catch(function(error) { console.error("Error adding document: ", error); }); Exception caught: (FirebaseError) : Function

Firestore web code sample gives invalid argument type

不问归期 提交于 2020-02-21 06:31:06
问题 I am trying out the new Firestore by Firebase. When I run the code sample from https://firebase.google.com/docs/firestore/manage-data/add-data?authuser=0, I am getting an error. // Add a new document with a generated id. db.collection("cities").add({ name: "Tokyo", country: "Japan" }) .then(function(docRef) { console.log("Document written with ID: ", docRef.id); }) .catch(function(error) { console.error("Error adding document: ", error); }); Exception caught: (FirebaseError) : Function

Pass value from GWT to Javascript via JSNI

天涯浪子 提交于 2020-01-25 12:04:08
问题 I've been trying to pass a value into a Javascript method through JSNI but it keeps on failing. Is this method valid: public static native JavaScriptObject getProductById(long pid) /*-{ var productId = pid; var product = $wnd.products({id:productId}).first(); return product; }-*/; I can say that the JS method is correct, since if I put a constant value in place of productId , I get the correct output. What am I missing? 回答1: JSNI does not allow using long as input variable, see explanation

From javascript to java (A GWT story)

大兔子大兔子 提交于 2020-01-24 05:15:28
问题 So, I'm designing an app in GWT for an embedded web browser (Sketchup). I can control Sketchup by changing the window.location value to "skp::myFunciton@myParams". Sketchup can execute javascript in the browser. What I want to do is ask sketchup to give me the contents of its model. public static native void getModel() /*-{ $wnd.location = "skp:getModel@"; }-*/; After a second sketchup has a result. But how do we get it back to gwt? The problem is the entrypoint instance launched the request

GWT, passing an ArrayList to JSNI

非 Y 不嫁゛ 提交于 2020-01-16 18:20:09
问题 In my GWT application I have a javascript function wich require an array of array as argument. I get the data using RPC, so I get a List< List > from my database. I need this because I have to fill a kind of tree view. For example, I get this from my RPC call: {"A", "A1", "A2"}, {"B", "B1"}, and I have to pass this to my javascript function: [["A", "A1", "A2"], ["B", "B1"]]. In my interface I want to show: A+ A1 A2 B+ B1 How can I pass it to my javascript function using JSNI? 回答1: If you can

GWT, passing an ArrayList to JSNI

做~自己de王妃 提交于 2020-01-16 18:19:30
问题 In my GWT application I have a javascript function wich require an array of array as argument. I get the data using RPC, so I get a List< List > from my database. I need this because I have to fill a kind of tree view. For example, I get this from my RPC call: {"A", "A1", "A2"}, {"B", "B1"}, and I have to pass this to my javascript function: [["A", "A1", "A2"], ["B", "B1"]]. In my interface I want to show: A+ A1 A2 B+ B1 How can I pass it to my javascript function using JSNI? 回答1: If you can

HTML5 and Javascript : Opening and Reading a Local File with File API

↘锁芯ラ 提交于 2020-01-13 06:55:42
问题 I am using Google Web Toolkit for a project and would like the user to select a text file to open in a text window inside the browser. Here's the almost working code: private DialogBox createUploadBox() { final DialogBox uploadBox = new DialogBox(); VerticalPanel vpanel = new VerticalPanel(); String title = "Select a .gms file to open:"; final FileUpload upload = new FileUpload(); uploadBox.setText(title); uploadBox.setWidget(vpanel); HorizontalPanel buttons = new HorizontalPanel();

GWT Linechart options

给你一囗甜甜゛ 提交于 2020-01-11 10:14:13
问题 I need to set different line width to different series in a chart. This can be done using the series option here http://code.google.com/intl/sv-SE/apis/chart/interactive/docs/gallery/linechart.html#Configuration_Options . However this option is not available in GWT which leads to my question. I could: Write a wrapper for GWT. http://code.google.com/p/gwt-google-apis/wiki/VisualizationNewWrapper Use the Options.set(...) method. http://gwt-google-apis.googlecode.com/svn/javadoc/visualization/1