Logo of Bento frameworkspaceObject Oriented Programming


JBuilder 2007

ViewGenerator

Free source code example for Bento framework...

Seeing is believing! First of all, please enjoy the example of Bento framework that is running on our web site. It is the simple photo Blog where you can upload the image files by your web browser (multipart/form-data), or e-mail with file attachment. After you grasp how it works, please explore its source code. The source code of the example is included in the FREE trial version of Bento framework.

[ Try and download example ... ]

View in MVC (Model-View-Controller) framework ...

This API plays a view part in the MVC (Model-View-Controller) framework. To grasp the whole picture of Bento framework, please read Introduction of Bento framework.

View by XML ...

Believe or not, all the response from your Servlet can be written in just the normal HTML (or any mark-up languages such XHTML, WML or HDML)! Unlike the JSP/JSTL based solutions like Apache Struts or JavaServer Faces, the web designers (or page authors) of your project need not know even a bit of the custom tag libraries. Once the GUI for the response is written in the normal HTML, it's time to run HtmlToXml conversion tool:

Screen Shot of HtmlToXml

This tool converts the normal HTML into the template XML. You can also update the template XML by HtmlToXmlEdit, another GUI tool in this Java API.

Screen Shot of HtmlToXmlEdit

Both of these tools are included in ViewGenerator API. When you finish the template XML, please place them into:

or its sub-directories. ViewGenerator API reads the template XML, insert the arbitrary Strings between the fragments of tags in the template XML, and send the concatenated tags back to the web browser. By this way, your Servlet can generate the dynamic response from the template XML, that is converted from the normal HTML (or any mark-up languages such XHTML, WML or HDML).

Command line tool for generating XML ...

While above 2 Swing GUI tool are the easy to use, it may take much time to convert many HTML, because you need to convert them to XML one by one. To make the things easier, the command line tool is included in this API. All you need is to put a set of special comments into the source HTML.

[ README for command line tool ... ]

Input validation from CGI FORM ...

While interacting with the user, each text field in your CGI FORM expects the specific pattern of input. For example, the user should type only the digit (0-9) in some text field of your CGI FORM. If s/he sends the wrong input, the destination Servlet should detect it and show the same CGI FORM again. But the CGI FORM at this time should include all the previous inputs in it as the default value. In addition, the wrong input should be highlighted by the colored font or something:

CGI FORM with invalid input

By the help of ViewGenerator API, a few lines of code are enough for the input validation in your Servlet. When you work with HtmlToXml, you can specify the acceptable data type for each request parameter from the CGI FORM:

Acceptable data type for request parameter

Along with the set of the HTML tags, these information are also written into the template XML. Given these information from the XML, your Servlet can check all the request parameters at once. Please click the link below and look into the source code fragment:

[ Source code example ... ]

Note that the source code above does not bother about the validity of each request parameter from CGI FORM. Based on the information in the XML, ViewGenerator API checks the validates of all the request parameters, and this is why a single line of code is enough. For details, please read HtmlToXml Tutorial 1.
ViewGenerator API works with:

[ OOP RequestParser API ... ]
[ OOP ServletWorker API ... ]

and the source code above implements ServletWorker interface.

Easy localization (L10n) ...

In case of the JSP/JSTL based solutions like Apache Struts or JavaServer Faces, the localized messages should be written in the property resource file for each Locale. In the template solution by ViewGenerator API, the localization (L10n) of your Servlet is much easier. Please prepare the normal HTML in as many human languages as you like (each of them will includes the localized message for the expected Locale). Because all the localized messages can written in the normal HTML, there is no difficulty even in the 2 byte characters such as Japanese Shift_JIS, Chinese BIG5 or GB2312. Once you prepare the set of the HTML, please run HtmlToXml conversion tool on the HTML for each Locale and place them into the different path. For example, you may have a set of template XML like below:

And the deployment descriptor of ViewGenerator API associates the path information of the HTTP request with these XML.

View for each host ...

Apache Tomcat behind the Apache web server (HTTP daemon) can accept the HTTP request for more than one host. And one set of Servlet/JSP on Tomcat can accept the HTTP requests with various host headers. On this kind of configuration, you may need to allocate the different View for each host. The deployment XML of ViewGenerator makes it easy. For details, please click the link below and read another page.

[ View/Model for each host ... ]

Read Java doc / FREE Download

You can read the Java doc for this API online. Or it is included in the trial version of this API and you can download it at FREE.

Java doc README
Trial License Product License (PDF)
Download

Copyright © 1997-2008 OOP-Research CorporationTM, All Rights Reserved.

Valid XHTML 1.0! Valid CSS!