NetBeans Screenshot of the Week 42: JavaScript Native Interface

At the Roundup last week I talked to
Robert Cooper, who's doing a lot of interesting work with GWT (Google Web Toolkit). In GWT (which compiles Java to JavaScript), you can embed JavaScript directly within the Java files inside comments with special markers. Robert mentioned that IntelliJ has a nice feature for GWT programmers where your native JavaScript snippets get JavaScript highlighting etc.

I figured that would be a trivial thing to add to NetBeans with our language embedding infrastructure. Sure enough, the patch just adds 13 lines of code. Here's a screenshot - showing JavaScript (regular expressions etc) inside Java code (with packages etc) - it's inside comments that start and end with -{ and }-:

If you want this functionality in your own 7.0 build, just download this module nbm, or apply the patch to your own build.


7.0 or 6.7?

I'm confused by version numbers these days... ;-)

Posted by Tim Yates on March 16, 2009 at 04:32 AM PDT #

Doh, I meant 6.7. We originally planned a 7.0 but then switched to a model with shorter releases. I -think- the plan is for 6.7 to be out in about three months.

Posted by Tor Norbye on March 16, 2009 at 04:42 AM PDT #

Hehe, just keeping you on your toes ;-) Looking really nice :-)

Posted by Tim Yates on March 16, 2009 at 05:46 AM PDT #

oh, I like that... :-)

That'll make editing of GWT files a first class experience.

Does anyone know why google appears to favour eclipse ? see They do not appear to mention NB at all.

Posted by Nigel Leck on March 16, 2009 at 03:37 PM PDT #

hi Tor! help me please - NetBeans doesn't show cyrilic (it shows only placeholder for character as square), though I can type it, save, and see with another editors. Sorry for asking here, but cannot find in google why it so. Thanks

Posted by ruby.freeman on March 18, 2009 at 03:35 AM PDT #

plz say me sme logic to set two calss for a div

Posted by vinoth kumar subramanian on March 29, 2009 at 06:48 PM PDT #

I am maintaining 2 NetBeans Plugin Projects.
Will you help me to enhance these projects.

One is nbopenlaszlosupport.
This plugin adds support for OpenLaszlo, a Flash-based Rich Internet Application web framework.
It allows you to develop RIA applications using XML and Javascript on the UI and Java on the server, without any knowledge of Flash itself.

Other is REM.
REM is a NetBeans module for ZK application development. It can be used to create ZK web Applications, ZUL and ZS documents. It supports ZUL syntax highlighting, auto indent, code folding, code hyperlink navigation and code completion.

I want to enhance the code editor to add embedded code completion ability of scripting.

Embedding JavaScript Code Completion to Openlaszlo:
This is the sample xml format Openlaszlo design file.
Inside each tag:<script>,<method name='name'>,<handler name='name'> JavaScript code is used.
<canvas xmlns="">
<script><![CDATA[ ]]></script>
<method name='name'><![CDATA[ ]]></method>
<handler name='name'><![CDATA[ ]]></handler>

I want to embed JavaScript Code Completion capabiblity to this plugin.

Embedding JavaScript Code Completion to ZK:

The core of ZK consists of an Ajax-based event-driven mechanism, over 123 XUL and 83 XHTML-based components,[4] and a markup language for designing user interfaces. Programmers design their application pages in feature-rich XUL/XHTML components, and manipulate them upon events triggered by end user's activity. It is similar to the programming model found in desktop GUI-based applications.

Embedding scripting support with Java (Beanshell [2]). This is an important benefit as you can use a unified programming language for both user interface and backend programming. Optional support for other serverside Java scripting in other languages such as JavaScript (Rhino [3]), Ruby (JRuby [4]), Python (Jython [5]) and Groovy [6]
A page could have scripts in multiple different scripting language.

<zscript language="Java">
var1 = 123;
<zscript language="JavaScript">
var2 = 234;
<zscript language="groovy">

If the scripting language is omitted, Java is assumed.
Each scripting language is associated with one interpreter. Thus, variables and methods defined in one language are not visible to another language. For example, var1 and var2 belong to two different interpreters in the following example.


Posted by Sotohito Terashima on April 21, 2010 at 04:02 PM PDT #

Post a Comment:
Comments are closed for this entry.

Tor Norbye


« February 2016