Webby Examples

Buco: Lots of Contacts in just about 400 lines

The latest example of webby usage is called Buco and aims at showing how to manage business contacts and organizations, enabling sorting and filtering where needed and this time using no introspection but explicitly created descriptors to enable webby.

The name Buco is just the abbreviation of "BUsiness COntacts" ... please forgive my lack of creativity here.

Probably noteworthy details:

  • Buco is implements in just 4 Java files, two for the business classes (Contact class, Organization class), one for the application itself (demanded by wicket to have this), and one for the home page.
  • Buco is implemented in less than 450 lines of code.
  • Buco contains one action that is completely useless in a real applcation, but just meant to allow the test users to fill the database quickly: Try Add lots of random contacts in an organization, see what it does and look at the source if curious.
  • Organizations can only be created indirectly via a contact by using Create new Organization for this contact.
  • Deleting a business object is not dealt with nicely yet. Something to be worked on for a next webby release.

How to obtain

You can get the sources for Buco directly from the maven repository or browse it at the svn repository.

How to run

You can run it directly at r8fe.net.

If you want to run it yourself:

Just as webby, also Buco needs Java 1.5 to run. If you are reading this, you most likely know how to obtain it...

One option for Buco to run is to get the ready-made war archive and deploy it to your favorite servlet container. (You also need a database, which you can do by executing step 1 below.)

Now with maven making dealing with dependencies so much easier, you can also download the source and do a

mvn jetty6:run

to immediately run it on your machine locally -- no, wait, two pieces are missing in this case:

  1. You need a local mysql database, named as in src/main/java/hibernate.properties in Buco's source.
  2. Due to licensing issues the dependency to the JTA interfaces cannot be downloaded by maven, but must be downloaded by yourself. See the Special Dependencies of databinder for an easy description on how to do this.

New buco example

Check out the new buco example (called buco2). A description about what is new and why it exists can be found in the blog soon.

An online order book

This example intends to show simple usage of webby: the orderbook example is a not-really-usable implementation of an orderbook application: You can create articles which are then available for orders: Orders have got order items which reference articles, and have got a quantity. Based on the selling price given in the articles, some simple calculations are built into the model and hence shown as (readonly) attributes in the lists and forms.

For the implementation we take a simple business model (package model) and use as little Java as possible to create a usable web UI.

Please be surprised that this example takes less than 600 lines of java code!

Concepts

You can see the following concepts in action:

  • Definition of a simple Configurator such that webby can introspect your business model classes.
  • Annotation of action such that the introspection of webby makes them available in the UI.
  • Implementation of actions in the applcation itself, i.e. without an annotation.
  • A HomePage that redirects to an instance of a BeanEditPage of webby.
  • Usage of hibernate together with webby.

Try it!

The example can be tried live at r8fe.net.

The source can be browsed in the subversion repository. See for example the following model classes:

Projects News Application

This example aims at showing how to extends Webby's UI components.

Additionally an extra property panel is used (via an annotation on the business class) to edit and display text in textile format.

Try it here.