I'm trying to use a GWT button to call a FileUpload using the .click method. I was struggling with getting code to trigger after a file is selected using this method. I've tried using an addChangeHandler but it doesn't seem to be calling once a file is selected.
Any help would be appreciated,
Thanks!
If you use the lastest GWT 2.8.2, you will use Elemental2 and JsInterop (the correct approach right now; please find an explanation here: https://stackoverflow.com/a/52083441/5394086).
Then please find some examples below.
An implementation for native browser's API: https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/File_drag_and_drop .
It's a modern one with "drag'n'drop" instead of "click", hopefully you will like it.
The first example uses GXT for the UI, but the upload stuff will be the same for generic GWT, so it's easy to modify the example for your purposes. The animated gif shows how it works. What more, it works without additional effort with drag'n'drop.
https://gist.github.com/branflake2267/d424e4a0c0b371e3dd9d15bfd3514429
Another example with JSNI is currently kind of deprecated approach:
https://gist.github.com/branflake2267/97266601f0f225ae2a750fc8115dc2c4
Finally a very nice Java8 lambdas and also very compact example using only free libraries, since Elemental2 is a part of the "new GWT" and Elemento is open source (https://github.com/hal/elemento):
https://gist.github.com/ibaca/a8a84b6e7b63259109fd782d7dbadd8d
I hope you will find it useful.
Related
I am trying to implement the DataSet type as described in the oracle docs here to later be implemented with a DataTable as described here. However, I can not seem to find the right library nor the right way to implement this datatype. Any help would be appreciated as every import I try doesn't know what the type is and I have tried to add the swingx library in addition but to no avail.Just as a note, I have tried the swingx library from here. However, even with added the import manually it still doesn't know this type. Is it possible the package changed since it looks like that documentation is from 0.8 when the library itself is much later?
org.jdesktop.DataSet is part of the SwingLabs API, whose website you can find from here.
The releases are located under downloads.
Edit:
I think I found a more complete package of the SwingLabs API... At the very least it should contain the dataset package. Link here
I have searched for ages but couldn't find what I am looking for.
I'm using highCharts.
Is there a method or project or something that creates generic highcharts charts for me? Currently I must make a javascript chart function for every chart I want. I want to make this generic.
So that I only have to ask the method getChart('line','etc'); something like this.
This way i dont have to code everything over and over again for each chart that I want.
(its for a Dashboard )
If this doesn't exists at all I will make it myself.
There are several libraries out there for producing highcharts. Many are listed on the highcharts download page here: http://www.highcharts.com/download under 'API Wrappers:'.
If you are most confortable working in Java, maybe you should check out GWT and the GWT Highcharts wrapper. GWT lets you write Java code, which compiles down into javascript.
Those ones are the bests http://www.highcharts.com/ i tried them and they work absolutely fine with great design just download them and make us know if you get problemes using them.
I have looked at many of the other similar questions but none of them seem to have a precise answer.
I'm working on an Android app that works with a lot of images. I am looking to add information to images by editing the value of their IPTC keyword tag (or other appropriate tags). I am using Metadata Extractor for reading metadata but this library doesn't support writing metadata.
I have looked at Apache Sanselan which doesn't seem to be appropriate because it has heavy dependency on java.awt (which is not available in Android). I'm aware of Imagero but I have not used it yet in the hope of finding a better open source library.
Has anyone come across such a library? I prefer it to be open source but even commercial suggestions would be appreciated.
Thanks in advance.
https://github.com/k3b/pixymeta-android/ is a fork of https://github.com/dragon66/pixymeta-android/ that implemented
single source for android and jave2se/awt
However there is still a lot of work to implement a simple to use api
Use http://sourceforge.net/projects/iim4j/ Won't work out of box, but can be adapted. I did it to add Copyright notice and Contact fields. Didn't tried other fields, as I didn't needed them. So that would be your bet.
Sorry, can't share the code.
I am trying to build a search engine using java and the lucene API as part of a project. For the last step, we plan to build a web UI (a local host would do) for the same. Are there UI softwares/plugins for eclipse which will allow me to call the functions present in the java classes?
Essentially I would want to have a search box and a search key, pressing which will throw up the search results(which is computed from the java program). javascript cannot call java code I understand. So using that is eliminated?
Any suggestions on what to use will be greatly appreciated. I have pretty poor knowledge in front end design!
Cheers!
AB
If all you have is a simple screen with a entry field and a button and you simply want to return an html table. I would go with a servlet and two jsps. Your servlet can call your search engine and then have the jsp format the data into the table. If you do not know web apis this is probably the easiest entry.
I think, If your using JAVA, that you should look into JSF.
It's a rather easy to maintain and work with library for just the uses you describe.
I recommend these tutorials to get you started: http://www.coreservlets.com/JSF-Tutorial/jsf2/#Tutorial-Intro
There are lots of options to achieve this.
you can create web-ui using jsp.
I have also created same type of project using Lucene, here i have used spring mvc.i have provided all the back-end process as REST api which any web-ui can use.
Please do not look into JSF; it is an overengineered pile for your task.
Sure you can call your java code from javascript, you can make it really simple with something like DWR.
However, for your project I would suggest GWT as then you only deal with Java and it will generate javascript, html and css for you.
For your project you dont really need an "enterprise" level framework like spring or a fullstack JavaEE, you could keep it real oldschool with only JSPs and html/javascript. However thats a bit too flaky for my taste, so go with GWT.
With GWT you basically set it up, define your module, entrance point (look at the hello world), and then you add a layout to your page like something to place the searchbox into and the resultbox to. Then you call your other Java code and classes from there like you normally would.
I would suggest you to use GWT in your application because GWT enables you to call java methods and it will also convert Javascript and css for your Java modules after GWT compile.
GWT reference :- http://code.google.com/webtoolkit/gettingstarted.html
If you're going to use GWT, you could aslo check Vaadin.
Creating a search UI is really simple, and the tutorial show a criteria /result table application taht could be adapted.
I want to know if it's possible to execute a javascript function from java. Basically I have a javascript function to which I want to pass a string and then get the output from that function.
If it's possible, how do I accomplish it?
EDIT -
I couldn't find a solution to this, what I did was re-write all the javascript code in Java. But I am guessing, Rhino ported on Android should do the trick. If someone has tried it out, please post a solution.
You probably want to take a look at the ScriptEngine. There are plenty of samples out there on how to use it. Works on anything but Mac where they for some reason selected to include AppleScript instead of JavaScript by default.
Edit: Take a look at this page, there seems to be a Rhino port for Android out there.
Javascript is not natively supported in java. If you need it, you may implement the Rhino javascript engine to do this.
"Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically embedded into Java applications to provide scripting to end users."