Java Tutorial - Java Script :
Barracuda
Barracuda is a first-class framework that comes from the Enhydra project that was originally created by Lutris Technologies. Although Lutris Technologies did not survive the dot.com crash, the open source Barracuda framework that Lutris created did survive. ObjectWeb now sponsors Barracuda and the other Enhydra-related projects. Barracuda, much like the other frameworks we discuss, provides classes that allow the developer to develop Web applications faster, more easily, and with fewer bugs. The product summary is provided in
the following table.
The primary mechanism for implementing the framework in Barracuda is the utilization of the server-side component model that itself implements widgets such as tables, lists, and templates to manipulate XML/HTML (*ML) templates that have been compiled into Document Object Model (DOM) objects. A tool supplied with Barracuda called XMLC handles the compilation of these *ML templates. The idea behind Barracuda is to provide a cleaner separation of code and content because there is no need to introduce scriptlets, or for that matter any server-side programming logic, into the markup. The “View” does not “pull” data from the model object similarly to most template engines or conventional JSP and Java Beans. Under Barracuda’s “push” model, the controller (servlet)
is used to manipulate the view directly through the DOM interface. Another nice feature is the Barracuda Event Model, which allows the developer to design events into the Web client application. These events are analogous
to the event mechanism provided by the Java AWT user interface. The firing of an event on the client component notifies a server-side event handler so that it can invoke its event logic. Most applications that are international in scope are faced with language issues that need to be dealt with. The solution to this problem is commonly
referred to as localization. Historically, two approaches have been taken to deal with this issue:
· The designer develops duplicate versions of the content, and the appropriate version is served up depending on the target client locale. Clearly, from a maintenance standpoint this is not desirable.
· The content is served dynamically, depending on the target client locale; of course, this solution suffers from the cost of high overhead.
Barracuda’s approach to localization is novel to say the least: The userdevelops his or her base content HTML/XML file and a suite of property files with appropriate keys and text for the various locales supported. It is important
to note that the original base HTML/XML file does not contain any ID tags that correlate to the keys in the property files. It is also important for the base locale properties file to contain text that is exactly the same as that in the base
*ML file. The XMLC compiler can then use this comparison to derive the appropriate key for the subsequent locales. After this has been done, the XMLC will then recognize all of the locales and, with the help of the XMLC Localization Taskdef, produce compiled output for each of the locales. Working in a fashion similar to the way GUI-based Java programs use the Java Resource Bundles, the DOMLoader returns the previously compiled output based on the requested class name and locale automatically, alleviating the aggravation to the developer of determining the locale and calculating the appropriate template name. The final feature we must mention is the Barracuda Form mapping and validation framework. Mapping involves taking an HTTP request form and mapping the form elements into Java objects. These objects can then be validated by subclassing the DefaultFormValidator class and writing specific validation logic for the mapped fields.
