Monthly Archives: July 2006

Test Driven Development by Java2Script

Now, Java2Script support JUnit for Test Driven Development(TDD) in developing RIA.

To do so, please set up the J2S development environment from SVN repository. If you would like to learn more details about JUnit support of J2S, you may need to checkout the project net.sf.j2s.java.junit.

After setup J2S environment, do your “Hello J2S World” examples for sure. And then create or import your testcases or testsuites. Make sure that your tests pass in Java’s JUnit test. And then “Run as…” -> “Java2Script Unit Test”, your tests will be run in console mode. You may come up with some failures in Java2Script mode even though all tests is passed in Java mode. For example, assertEquals(new Float(1.0).toString(), “1.0”) may result in comparing “1” with “1.0”, which will be considered as failures. Try to report bugs or try to avoid such buggy way.

Currently, JUnit tests over SWT are not supported yet.

Java2Script’s JUnit support will be in the next milestone release scheduled on middle of August.

Posted in How To, Java2Script News | Leave a comment

Loading J2S SWT Application Inside Existed HTML Pages

See the home page for inline demo or visit http://j2s.sourceforge.net/j2s-demo.js for more details.

It seemed that sourceforge.net was very slow for my network location. I had to refresh one or two times to get all *.js correctly loaded. And it seemed that waiting for every *.js is a very boring experience.
Enjoy the inline demo.

Posted in Java2Script News, JavaScript | Leave a comment

A Link An Application

For example:

javascript:(function(){var d=document,b=%22http://java2script.ognize.com/1.0.0-m3/%22,t=%22onreadystatechange%22,x=d.createElement(%22SCRIPT%22),f=function(){var s=this.readyState;if(s==null||s==%22loaded%22||s==%22complete%22){var c=%22org.eclipse.swt.examples.controlexample.ControlExample%22;$CL1(b);$CL2(b+%22../control-examples/%22);$CL3(c,function(){eval(c+%22.main([]);%22);});}};x.src=b+%22j2slib.js%22;(typeof x[t]==%22undefined%22)?x.onload=f:x[t]=f;d.getElementsByTagName(%22HEAD%22)[0].appendChild(x);return;})();

will link to an SWT control examples. We can also call this as “A Link An Application”(ALAA).

OK, let’s see what is going on. Now load SWT control examples from java2script.ognize.com (test site only, may be slow and unstable, enjoy it) into this page.

Or, you can copy the link of SWT control examples, and then visit a new HTML page, for example, visit Google, and then paste the link to the location, and then go. You should find the SWT control examples will be loaded inside Google’s page. All you dealing with is just a link! But you alreay get an application everywhere inside your browser.
Users can also bookmark the “javascript:…” links. To bookmark a “javascript:…” link, you should first bookmark a normal HTML page, and then copy the “javascript:…” link location and paste as URL location in the bookmark’s properties dialog. Some browsers (e.g. Opera) will let you change URL when you’re bookmarking without a later modification of URL.
And whenever users want to load the application, users can click the bookmark, which will bring up the application in users’ currently visiting HTML page. For example, if you have already bookmarked the above SWT control examples application as “javascript:…” link. And if you are visiting visit W3C, and you can click the bookmark, and the application will be loaded without leaving the W3C pages.

That is the mean of “A link An Application”. A “javascript:…” link is an application, which may be hosted inside any given HTML pages. And the “javascript:…” link would be a very useful and complicated application besides those simple “javascript:history.go (-1);” or “javascript:alert(document.lastModified);”. So there are chances that you can deliver your useful and complicated web applications via generated “javascript:…” links into any other HTML paes or other web applications.

You can also considered the “javascript:…” link as plugin extensions to the browsers that needs no installations (Only bookmarking). There are plugins for Firefox or IE. Most of those plugins need installations and may also need manually updates or uninstallations. But the “javascript:…” links is free of those deployment instructions. All the application is just a “javascript:…” link. That is enough simple.

A link is an application. An application is a link.

Posted in A Link An Application, ALAA, Java, Java2Script News, JavaScript, Sharing, SWT | Comments Off on A Link An Application