Author Keith Wong, firstname.lastname@example.org
Last updated: 23rd Feb 2002
Click here to download the toolkit.
The Objective HTML (OHtml) toolkit allows programming of HTML forms (in Java) in the style of traditional client-server GUI toolkits. Its aim is to make maintenance and development easier through encapsulation of form components into Java objects.
These are some of the features offered by OHtml:
Whilst templating based frameworks are excellent tools for building content based pages, they are an unnatural fit for form based pages. A html form consists of interactive components and like any GUI application these components are best modelled with Java objects. Having these form components as Java objects allows it to maintain its own state and allow it to have properties that it otherwise wouldn't have in a templating framework. Using an object-orientated methodology for GUI applications has been a long proven solution and it is the aim of OHtml to bring to Web developers the same benefits and advantages of this methodology.
How OHtml Fits Into Your Project
OHtml is not meant to be a complete MVC solution. The toolkit was designed to be light-weight component that can be plugged into almost any other existing Java framework such as Struts, Velocity, etc. The toolkit aims solely at providing an easier way to build and maintain html forms.
Strengths And Features Of Objective Html
Clean Separation Of Page Design And Logic
The OHtml Compiler (ohtmlc) gives you the ability to generate OHtml Java code from normal html files. Because your page logic resides in your Java object, your html page need not be corrupted with scriptlet code and/or custom tags. This way your html developers can always modify the form design by using the favourite WYSIWYG html editor.
By using OHtml you gain all the benefits of OO programming. Instead of having to fiddle your way through html code, you build your html forms using Java objects. All form elements are encapsulated in Java objects. This allows you to keep your code neat and in the one style as oppose to having to use a complex mix of html and scripting code. As objects your html elements has properties which it otherwise wouldn't have. All textual objects have automatic escaping of special html characters and all objects can be made hidden.
Intuitive Data Handling
The toolkit encapsulates html form data inside Java form objects. Instead of having to work directly with posted data, developers can access data through these objects. For example, if you have a HtmlCheckBox object on the form, you can verify whether the check box was check simply by calling the method isChecked() on the object. You don't have to bother checking what data got posted back in the request object and you don't have to update your html code so that the check box will be drawn next with a checked attribute. All this is magically handled for you by the toolkit.
By using the signals and slots mechanism offered by OHtml you can capture client-side events on the server. Signals are emitted by objects that wish to inform other objects of something that has happened to it. The HtmlTextBox object, for instance, emits the valueChanged signal when its text value is changed, and the HtmlPushButton object emits the clicked signal when the object is clicked. Objects (the slots) that are interested in these events can connect to these signals and the slot method will execute when the signal is emitted.
By integrating Objective Html with Struts developers can configure their Objective Html forms using xml configuration files. In these configuration files you can specify the signal and slot connections for a form and between forms. You can also specify how the forms are to behave when a Objective Html/Struts action is triggered. This flexibility allows developers to build highly self-contained forms that are loosely coupled with each other and highly reuseable. The behaviour and interactions of the forms can be easy configured in the xml file for a particular problem domain.
View Access From The Controller
The toolkit provides an implementation that is much more cohesive than with typical templating frameworks. In a typical templating framework the model (Bean), the view (Jsp) and the controller (Java Class) are uncohesive to the most extreme. Say for example your current business logic tells you that you must disable a certain field on the form. To do this you must first identify this logic in the controller, set a boolean flag in your model and then have the Jsp page extract this boolean flag and process it. So for your controller to do what it wants (to disable a field), you must go through the model and then the Jsp. These extra layers make it much harder for people to understand your code (especially when you start adding more flags for other things) and as well gives your application many more points of failure. Using Objective Html you end up with only one class that represents the html form, that contains all the data and also contains the presentation logic for the form. So in this example when you identify that this field needs to be disabled you are able to do this immediately and in the one place as you have access to your view from the controller.
Supports Multiple Output Formats
Your html can be written out in either standard Html or the new Xhtml format. Because all your form elements are encapsulated in objects you can choose the output format of your forms dynamically. More Html variants may be supported in the future.
Minimal Html Knowledge Required
The toolkit abstracts all the low-level html code away from the developer. The object hierarchy used by OHtml is very intuitive and allows people with a basic understanding of html and general concepts of user interfaces to start building rich user-interface web pages.
Click below on the links below to see some tutorials.
Tutorial - An Introduction To Objective Html
Tutorial - Using Objective Html and Struts (DEPRECATED)
Tutorial - Separating Page Design and Logic
Tutorial - Signals and Slots
Tutorial - Objective Html Compiler
Tutorial - Using Objective Html and Struts Advanced (NEW)
Objective Html With Struts
Click here for more details on Objective Html With Struts.
Objective Html Compiler
Click here for more details on ohtmlc.
Signals and Slots
Click here for more details on the Signals and Slots mechanism in OHtml.
Click here to see the signals available on each HtmlWidget.
Objective Html - Class Hierarchy
For an overview of the classes in the toolkit and the class hierarchy click here.
Objective Html API
Javadocs for Objective Html
Support - Emailing List
There is a general user emailing list. Click here to subscribe.