Web applications with GUI generation via embeded EulerGUI

© Jean-Marc Vanel - $Date: 2012-02-12$ - under Creative Commons License by-nc-nd 3.0

TOC

Introduction

The Rule based Swing applications includes a rule base generating forms form OWL ontologies. This rule base is designed to run with other GUI API's than Swing, like Java bindings to Qt, GTK, etc. There is a compatibility layer based on an ontology for generic GUI's.

However, it has never been used for anything else than Swing. A Web example is particuliarly interesting to develop a rule-based Web application with domain plus applicative logic.

The ingredients

We considered several object oriented Web page frameworks: GWT, Echo 3, Apache Wicket. The latter looks the most promising, because a part (only) of the HTML page can be managed by the Web page framework, and thus by the rule engine. Look at this, pasted from Apache Wicket introduction :

But Wicket applications are not like applications written in either Tapestry or Echo, because in Wicket you get the best of both worlds. You get the benefits of a first-class component model and a non-intrusive approach to HTML. In many situations, this combination may prove to be a significant development advantage.

Recipe

  1. install EulerGUI sources and build (uses Maven)
  2. download Déductions project rules and samples:
    svn co https://deductions.svn.sourceforge.net/svnroot/deductions
  3. run with EulerGUI this project :
    deductions/n3_nojs/person-app.n3p

    ( see here for details : Running the project with imported Déductions rules )

  4. open this file in the swing3.n3p rule base:
    deductions/n3_nojs/generic_to_java-rules.n3

    It has a bunch of rules to generate Swing objects and adapt predicates representing method calls, like:

    { ?W a gengui:TextField.
      javapr:thisApplication app:platform app:Java .
    } => {
      ?W a java:javax-swing-JTextField } .

    The highlighted URI representing classes have to be adapted to Wicket ( or Echo 3). Copy the original file as generic_to_wicket-rules.n3 .

    Save a copy of the swing3.n3p rule base with generic_to_wicket-rules.n3 as wicket.n3p .

    Save a copy of the person-app.n3p project with wicket.n3p instead of swing3.n3p as person-app-wicket.n3p .

  5. follow Wicket's Quickstart (uses Maven)

    ( you may want to use richer Maven archetypes : More archetypes )

  6. Call from Wicket Quickstart Java code the EulerGUI API ( see "Running a stateful Drools engine" ), to open the modified project person-app-wicket.n3p you just created .
  7. Restart the Wicket Quickstart web server ; you should see the same generated form as the Swing project :

    generated_form