The big easy
This post describes how much easier it is to write applications with UltraLightClient ‘08 ( ultra easy, to repeat a recurring phrase). Unlike the previous posts in this series, this post focuses on use cases instead of features. You can find the previous posts discussing the new features in the upcoming UltraLightClient ‘08 release in the UltraLightClient category of this blog.
I will cover the following use cases in this post:
- How to setup a new project in Eclipse
- How to start with application development
- How to web enable my application
- How to write an application that runs in a browser and with Java Web Start
- How to implement a form
- How to implement a table
- How to sort tables
- How to internationalize an application
- How to change the style of your application
- How to use a custom look and feel
- How to define the log level, the file service, coders, protocol encoding, …
For each use case, I will flash back to the current version to highlight how the new release will make the overall development process smoother.
How to setup a new project in Eclipse
Start the project wizard that is installed as part of the UltraLightClient ‘08 release. The project wizard guides you through the process of setting up a new Eclipse project.
How it was before
Create a new Java project. Copy all relevant libraries into your project. Attach source code for these libraries.
If your project requires client-side code, things become even more complex. Create a new extension project and connect it to your application project. Again, copy all relevant extension libraries into your extension project and attach the source code.
How to start with application development
The new project wizard helps you start application development. Besides the projects, the wizard creates an end-to-end sample application that you can use as a kick start. End-to-end means from user interface to the database! The sample application contains best practices that evolved from a lot of UltraLightClient projects.
Learn from the success of others!
How it was before
Read a lot of documentation. Start coding. Learn from your errors. Read the postings in the mailing lists. Continue coding. Learn again from your errors. While you get more experienced you will notice recurring patterns. After a while you are able to distinguish the good patterns from the ugly ones.
How to web enable my application
Nothing to do at all! The new project wizard has already prepared your project for web deployment. The only thing left to do, is to export your project as a WAR file! And as a bonus you can deploy and run your web-enabled applications from within Eclipse.
How it was before
Write a complex build script. Write a HTML/JSP page that embeds the ULC Applet. Configure that ULC Applet accordingly. If you want to support Java Web Start, write a matching JNLP file. Configure your application inside the Servlet deployment descriptor.
Ensure that you correctly configured everything, i.e. that your ULC Applet connects to your ULC Servlet and that your ULC Servlet connects to your application.
How to write an application that runs in a browser and with Java Web Start
Nothing to do at all. UltraLightClient ‘08 takes care of this for you!
How it was before
Write an application for Java Web Start and write an application wrapper for the browser that places the main window inside an Applet.
How to implement a form
Only one line of code for each field in the form! With this single line you get a nice form layout including end user error feedback. And UltraLightClient ‘08 automatically synchronizes your form and your data.
You can find more details about forms in a previous blog post.
@Override
protected void initForm() {
startTab("General");
addTextField("name");
addCheckBox("contractor");
addSlider("workload");
...
}
How it was before
No support at all. You have to write code for your layout, write code for error feedback, write synchronization code, … Lots of freedom, which results in non-uniform code and offers too many ways to get lost.
How to implement a table
Only one line of code for each column in the table. That’s all!
You can find more details about the configuration file in a previous blog post.
TableBinding tableBinding = TableBinding
.createTableBindingFromBeanList(persons, table, Person.class, false);
tableBinding.addColumnBinding("name");
tableBinding.addColumnBinding("contractor");
tableBinding.addColumnBinding("workload");
...
How it was before
Write your own table model. And in 99% of the cases you end up writing the same boilerplate code again and again.
How to sort tables
A one liner in UltraLightClient ‘08!
table.setRowSorter(new TableRowSorter(table.getModel()));
How it was before
Write a table model decorator. The decorator sorts the table model data of the underlying table model. And write an action listener that triggers the sort when the user clicks the table header. And write a table header cell renderer that displays a sort icon in the table header. And be careful when to use the table model decorator and the underlying table model.
How to internationalize an application
Name your user interface elements. That’s all! UltraLightClient ‘08 then auto-injects arbitrary property values from resource bundles into your user interface elements. And even better, for forms and tables UltraLightClient ‘08 creates default names. So you don’t have to do anything at all in your application!
You can find more details about the internationalization file in a previous blog post.
HelloApplication.properties
hello.text=Hello World! # default text for the hello label
hello.icon=hello.png # default icon for the hello label
HelloApplication_de.properties
hello.text=Hallo Welt! # german text for the hello label
hello.icon=hello_de.png # german icon for the hello label
How it was before
Get the resource bundle. Get the resource string out of the resource bundle. Convert the resource string into a property value (e.g. into an icon). Set the property value. And all that code looks more or less the same all the time…
How to change the style of your application
Style your components in the resource bundles. UltraLightClient ‘08 then auto-injects the defined styles for you.
# Heading style
Heading.font=SansSerif-BOLD-36
Heading.background=cyan
Heading.foreground=blue
Heading.opaque=true
hello.style=Heading # hello label uses Heading style
How it was before
Implement a component factory. All components need to be created through this factory. The creator of a component has to provide all information to create the component. Changing the style of a component required code changes in the component factory, in the caller class or in both.
How to use a custom look and feel
Configure the look and feel in the new XML-based UltraLightClient ‘08 configuration file. The configuration file is respected by all launchers: development, Applet, JNLP. Again, you can find more details about the configuration file in my previous blog post.
...
<ulc:lookAndFeel>
<ulc:lookAndFeelClassname>
org.jvnet.substance.skin.SubstanceGreenMagicLookAndFeel
</ulc:lookAndFeelClassname>
</ulc:lookAndFeel>
...
How it was before
Write custom code to set the look and feel and configure your launchers to use that custom code. The way to configure the custom code is different for each kind of launcher:
- Development => run time parameters
- Applet => HTML tags
- JNLP => xml based configuration file
How to define the log level, the file service, coders, protocol encoding, …
Use the same mechanism as for the look and feel, described above. Change the configuration in one XML file!

