I'm developing a web application with SmartGWT and I found an issue with Chrome. To solve the issue I modify part of my /war/projectName/sc/modules/ISC_Core.js. Following is the code I modify:
isc.Browser.isDOM?"
if(event.target.id.indexOf(\"Geoviewer_\") != -1){return true;}
if(returnVal==false)event.preventDefault();else if(returnVal==isc.EH.STOP_BUBBLING)event.stopPropogation();":"")+"return returnVal;"
The second line is the one I add to make the code work under specific circumstances in Chrome.
Now, unfortunately this is not a very 'clean' solution as I have to make the modification after the compilation because the file is generated after it. So my question is how can I find the piece of Java in the GWT code that is generating this Javascript so as to modify it once for ever and have the project compiling right without the necessity of further modifications?
Thanks for your help
The ISC_ Javascript files aren't being generated by GWT. SmartGWT is just a wrapper between GWT and a native Javascript library (SmartClient); it's basically the equivalent of a JNI AWT toolkit interface. If you have a repeatable bug, contact Isomorphic; they're pretty good about addressing demonstrable issues.
Related
I've been having terrible luck trying to get this to work, so I'm hopeful someone can help here.
In Java, I need to be able to take an HTML page with JavaScript within it and detect any JavaScript errors without, preferably without executing the JavaScript code.
I found this article:
Javascript parser for Java
And I've attempted to figure out how I'm supposed to use Caja to do this, but I'm having a difficult time finding any documentation with working examples of anything close to what I'm doing.
As a result I took a look at Nashorn also referenced in that article. I found a few examples which show how to execute JavaScript code from Java, but this doesn't process the whole HTML page. Even then, the execution doesn't seem to include the ability to validate common JavaScript functions (e.g. It hadn't heard of "alert").
Can anyone recommend something that might be able to do what I want, and point me in the right direction for their documentation or give me an example?
jshint as a standalone product seems to be a good fit for this:
it can run in java inside rhino (see https://github.com/jshint/jshint/)
a nodejs package exists (see https://www.npmjs.com/package/jshint)
it works with nashorn but it's quite tricky
I will only cover the technical difficulties around 3rd solution as I finally managed to make it work too...
Spoiler alert: "alert()" is not detected yet... Solution nb 2 will help there...
You first need to grab this specific release of jshint: https://github.com/jshint/jshint/releases/tag/2.4.4
Anything later than v2.7.0 will fail for now and I personally gave up patching intensively prototypes and namespaces... Releases from v2.4.4 until v2.6.3 work without modification but are limited in functionalities.
In the release notes, it's specifically written that "support for the Nashorn JavaScript engine" is working on this release. I'm using JDK8 nashorn 1.8.0_45 for this test.
Next step is to extract from this release this single file jshint-2.4.4/dist/jshint-rhino.js
Now you need to run nashorn/jjs in scripting mode and you need to be specific about the single file you wish to verify. In solution 2 (nodejs based) you can do multiple files or a complete hierarchy below a folder...
Create a simple file file.js:
function(){}
Now run the following command (please note the presence of -- ):
jjs -scripting jshint-rhino.js -- file.js
This will give you the following output:
Missing name in function declaration. (file.js:1:9)
> function(){}
So this covers the how to run jshint in a simple manner with nashorn... With the 3rd solution, at least you can find missing semicolons and several typical errors. But it's not a silver bullet and to me it's not a real alternative.
My personal preference would be to stick to solution 2 only. If you've the possibility to install either nodejs or iojs on your dev platform, go and grab https://www.npmjs.com/package/jshint. Not only will you be able to do more than the 3rd solution, you'll also be able to configure a jshintrc file as described at http://jshint.com/docs/
I like to inject js code into html when the application is done loading through Java. Actually, I have some code which I don't want anyone to see when they extract the application apk, and when that particular js in is embedded in Java code it would be a little difficult to extract. I know the complete java code for the apk can be decompiled, but this be make things little difficult.
Can anyone help in this?
I am using PhoneGap/Cordova 2.1.0 for Android.
Thanks
some solutions:
write plugin, call you code within a cordova.ready callback
extend the droidgap and call super.loadUrl("javascript:window.alert()");
I would suggest the first one.
I'm currently working on a project in Java, that will allow users to type Javascript code into a GWT Widget. How would I go about importing/using JSLint to check for errors? I looked around and found LSLint4Java, but I couldn't find the way to import it into eclipse. I just need a simple JS error checker that will check a string for errors.
If anyone has any other suggestions for error checking, please share them!
Thanks.
The JSlint javascript source can be found here. You could include the javascript in your WAR, reference it with a script link in your page(s), and make JSNI calls from/to your GWT code.
Note that JSLint has a No Evil clause in it's license:
// The Software shall be used for Good, not Evil.
Here's a good start on JSNI.
I'm trying to play with Scala in Android but the Manifest doesn't recognizes my main/only-so-far activity.
I did the set up according to this blog post: http://novoda.com/2009/10/17/scala-on-android/ and everything works until i try to run my app, moment in which the logcat saids that it just doesn't find my Activity. the thing is all i can found about this problem is this: http://tiliman.wordpress.com/2010/02/10/android-development-with-scala/. According to this post the manifest doesn't recognizes the Activity because it ain't a Java file, so he creates a Java class that extends from Scala, which i don't think is a good solution at all.
What do i have to do to get started? I think i'm not missing anything.
According to previously asked questions, there seems to be no solution, i mean no one provided one. But i can't believe that using something like sbt is the only way to make full and substantial Android apps in Scala. Truly, no solution at all?
UPDATE: As for the answer given, i'll give SBT a try. But i still think that is necessary a more straightforward way to do it. In a Google Dev Fest i attended, Tim Bray practically said that you could jut make Android apps in Scala or in Java, naturally and without problems: i don't see how this fits with Manifest doesn't recognizing a Scala activity.
The page you're looking at is pretty old. I'd recommend using AndroidPlugin, which is built on top of SBT (https://github.com/jberkel/android-plugin). It handles building, testing, deploying to the emulator/device, etc.
I've got this building my android app, and the only java file I have is the autogenerated R.java.
With SBT you can also generate IDEA and Eclipse configurations, so you should be good to go.
The solution posted here uses the AndroidProguardScala plug-in, in which if the name of the scala file matches the name of the main activity, there is not problem to have your main activity written in scala.
https://stackoverflow.com/a/11084146/1287856
I've found LINQPad to be extremely useful when answering StackOverflow questions for C# or VB.NET. It allows me to write up some quick code, run it, and (if I want) see a nicely-formatted dump of the results. That way I can be sure that the code I post actually runs. Thus far I haven't seen anything that I can use to achieve the same result with Java. Is there anything like that out there?
I am not looking for something to query data sources; I just want a light-weight IDE. These are the features I'm particularly interested in:
The ability to write and run short snippets of code without establishing a whole project or file structure.
Reporting of compiler and runtime errors in the code when it is run.
The ability to add references to a particular editor instance.
Syntax highlighting and Autocomplete/Intellisense would be a plus.
JPad - A java scratchpad for running snippets
Since I also couldn't find one I've decided to write one. Currently it can:
Run java snippets (no class / imports / public blah... needed).
Contains drivers for MS/MySQL/Postgres.
Output results as HTML tables
It's very rough but I will add to it over time. Feedback is definitely welcome.
This may help : http://www.browxy.com:9000/codeRunner
EDIT: Url seems to have changed to http://www.browxy.com
You can use the Groovy web console ; it's possible to speak java in groovy land.
Java Snippet Runner:
Does something similar to Linqpad (jar file, not just for macs)
http://mac.softpedia.com/get/Development/Java/Java-Snippet-Runner.shtml
Code Runner (Commercial):
for Mac's only, it'll run code snippets in Java, and lots of other languages too (e.g. Objective C)
http://krillapps.com/coderunner/
http://ideone.com is an online service that has the features you want.
I've been using JEdit for a long time, which is a very powerful cross-platform editor, NOT an IDE. It does have plugins to execute Java code right in the editor, and even uses BSH for macros.
I was looking for a "Java LinqPad" also, and i came across :
this
I've been using IntelliJ IDEA and it works really well as a Groovy scratchpad. The Community Edition is free too.
You need to create a new project, but then can add Groovy scripts to it and run them on the fly. Not had any luck with the actual Scratch File functionality though.
Being a Jetbrains editor it's pretty slick too. (Unlike some of the other options)
Nothing beats LinqPad though.