Eclipse Yoxos Services Downloads Blogs About
Home > Blogs >

Posts Tagged ‘javascript’

on Mar 23rd, 2012Client-Side input validation with RAP ClientScripting

The RAP team started working on a new feature called ClientScripting. It’s still in it’s infancy and will not (yet) be part of the core framework , but its already very useable. The goal is to allow adding pieces of behavior to the client-components of RAP widgets. This makes it possible to have swift, dynamic user feedback in situations that require a certain amout of logic – so far a problematic scenario for RAP applications. It can be considered an alternative to custom widget development in many cases, and might also save some network traffic. We currently focus on the scenario of validating text input while typing, and will expand from there. Interactions between widgets are not yet possible, but is planned.

As you can test for yourself, the difference between server-side and client-side validation is quite noticeable.

When using ClientScripting, you will need to know very little JavaScript, and all API is as close to SWT as possible. The project has a wiki page with all further information you might need (including where to get the code). Note that you need RAP 1.5M6 or newer to use it. If you try it out, please consider giving some feedback, report bugs or file enhancement requests.

on Mar 22nd, 2012CKEditor for RAP

If you ever need a WYSIWYG editor in your RAP application, look no further.

ckeditor CKEditor for RAP

I originally implemented this as an example of how JavaScript applications can be embedded in RAP as custom widgets. So if you have a similar scenario, you could also use this project as a template. The editor is fairly customizable, read the README for details. You can get the code on GitHub.

on Jan 26th, 2012Javascript validation with JSHint in Eclipse

Besides all the Java code in the RAP project, we also have more than 250 JavaScript files which total up to 75k lines of code. For such an amount of code, you should have some kind of code analysis that detects common coding problems like unintentional global variables. We use the JSEclipse plug-in for JavaScript editing which detects some, but not many JavaScript problems.

A while ago, we’ve tried to use JSLint, a tool written by JavaScript guru Douglas Crockford. Unfortunately, this tools produces several thousand warnings on our code base, many of them were not really problems but debatable coding style issues and there was no way to turn them off. JSLint’s lack of customizability recently lead to a fork named JSHint that is going to provide more flexible configuration options.

Like JSLint, JSHint is written in JavaScript, but can be run on the command line using tools like Rhino or JavaScriptCore. I tried JSHint on our codebase with good results using a shell script that runs it on top of Rhino. Unfortunately, checking all our 250+ *.js files keeps my machine busy for 5 minutes and 40 seconds and effectively turns it into a fan heater. This is not because JSHint itself is so demanding, but because for every file, a JVM has to be started, Rhino has to be loaded, then Rhino has to parse and load the JSHint JavaScript library, and then finally, jshint can parse and validate the source file.

Encouraged by the good results I tried to find a solution that doesn’t have this overhead. And as an Eclipse hacker and user, I certainly wanted to integrate the tool into my daily working environment. The result is a simple, yet efficient JSHint Eclipse integration that validates the same bunch of *.js files in less than 15 seconds.

jshint eclipse screenshot Javascript validation with JSHint in Eclipse

This speedup could be achieved by exploiting the way Eclipse builds projects: It uses the same builder instance to visit all files of the project recursively. That makes it possible to load and configure the JSHint library only once for the entire project and reuse it for all files being checked. Of course, validating all files of a project is only necessary for a full rebuild. During normal work, single files are being validated instantly when they have changed.

Although the configuration options are still somewhat basic, this integration proved to be very helpful already. I thought that it may be useful for others as well and decided to build and publish a first version. It’s available on the jshint-eclipse page. There’s an update site that let’s you install the plug-in right into your Eclipse IDE. If you find the plug-in useful, have ideas for improvements, find a problem or want to contribute, I’m happy to hear about it. To report problems, please use the github issue tracker.

on Jun 7th, 2011jQuery timeago in Java with RAP

A few weeks ago I showed you how easy it is to integrate jQuery into RAP using the browser widget. I’d like to show you another example of what can be integrated. Last time I created a carousel widget; this time the demo is something smaller but still really cool.

Yesterday I came across a github repository by Ryan McGeary. He has created a very clever jQuery plug-in called “timeago“. What this plug-in does is simple. It takes a timestamp and displays a text string instead of the stamp that describes the difference between the actual time and the one in the timestamp.  We’ve all seen the messages, “about a minute ago.”  The cool thing about this plug-in is that it refreshes automatically. I mean, it isn’t new to transform timestamps in this way, but it is usually done just once. So, when you visit a website in the morning and leave the tab open until evening, it still says something like, “The page was opened about minute ago” icon wink jQuery timeago in Java with RAP . This can’t happen with McGeary’s plug-in.

While having a jQuery plug-in is nice for javascript developers, it’s not as nice if you’re a Java Developer. But, fortunately we can integrate jQuery painlessly into RAP. As a result I wrote a RWT/SWT widget that simply maps the functionality of the timeago plug-in. You can set a date from the server and read the displayed text from the client.
timeago jQuery timeago in Java with RAP
If you like this idea you can grab the sources at github. Of course this is just a demo. Let me know if you would like to work with me on an implementation for productive use. Have fun with timeago icon wink jQuery timeago in Java with RAP

on Oct 14th, 2009Eclipse e4 1.0 M1 Released

Today, the Eclipse e4 project had its first 1.0 milestone release.

This is the beginning towards sprinting for the 1.0 final release.

The big new and noteworthy in this milestone is support for remote debugging of JavaScript and in particular e4 JavaScript bundles. The support is currently restricted to Mozilla Rhino, however in true Eclipse fashion, the JavaScript debug model and extension models are in place to allow supporting other JavaScript runtimes.

js debug 300x286 Eclipse e4 1.0 M1 Released

If you’re interested in Eclipse e4, here’s some resources:

Enjoy and please consider contributing to the e4 effort!

© EclipseSource 2008 - 2011