A Free Hotel Manager
Room Rack alpha library guide


The library is designed mainly to eliminate the redundancy of coding forms in Room Rack. This guide also would like to urge the users to use the library and soon it would evolve into maturity. Hopefully the library through this documentation would be appealing to programmers and by reuse, it would flourish into a functional tool in developing Room Rack.

There are 3 main classes in the library. RequestManager, PageFactory and FreeForm each of them can be seen at the basic diagram of Room Rack http://roomrack.sourceforge.net/roomrack_design.jpg


This is the only servlet in the library. Inside doGet() it creates an instance of PageFactory and depending on the parameters;

String s_display_page = a_req.getParameter("display_page");

S_display_page is passed to PageFactory. The PageFactory then responses to the request and construct a PageBuilder. The term PageBuilder by the way, is a subclass from AbstractPageBuilder

public abstract class AbstractPageBuilder {

String thePage;

String BuilderName;

public String getHTMLPage() {

return thePage;


public String getBuilderName() {

return BuilderName;




Back to RequestManager. After it receives the PageBuilder from PageFactory. Request Manager stores it in session. For upon loopback, it checks again the session that if there is an existing builder stored inside. The following code analyses the request btn_submit that is invoked from HtmlToolBarBuilder() which is also a subclass from AbstractFormBuilder()

String s_btn_action = a_req.getParameter("btn_submit");


AbstractUpdateablePageBuilder page_builder = (AbstractUpdateablePageBuilder)session.getAttribute("object/page_builder");


if (s_display_page == null) {

if (page_builder != null) {

if (s_btn_action.equals(HtmlToolbarBuilder.TOP)) {


} else if (s_btn_action.equals(HtmlToolbarBuilder.PREV)) {


} else if (s_btn_action.equals(HtmlToolbarBuilder.NEXT)) {


} else if s_btn_action.equals(HtmlToolbarBuilder.BOTTOM)) {


} else if (s_btn_action.equals(HtmlToolbarBuilder.SAVE)) {


} else if (s_btn_action.equals(HtmlToolbarBuilder.NEW)) {


} else if (s_btn_action.equals(HtmlToolbarBuilder.DELETE)) {




Now you might notice that instead of AbstractPageBuilder you see an AbstractUpdateablePageBuilder. Well AbstractUpdateablePageBuilder is a subclass from AbstractPageBuilder. It generally constitutes the class of any updateable form (FreeForm and Tabular).

public abstract class AbstractUpdateablePageBuilder extends AbstractPageBuilder{

public abstract int retrieve() throws SQLException;

public abstract int update(HttpServletRequest req);

public abstract int delete(HttpServletRequest req);

public abstract int insert();

	public abstract int top();

public abstract int prev();

public abstract int next();

public abstract int bottom();

public abstract int cancel();


So ReqestManager manages any incoming request. and there is only one

out.println(page_builder.getHTMLPage()); and each of the page builders generates their own html form.


Well itís a design based from the Factory pattern. There are plenty of java design pattern articles on the net but this link was the only one saved in my bookmark http://rampages.onramp.net/~huston/dp/patterns.html try to figure out what pattern is also recommended in the library.

Basically a factory returns an object depending on the parameters it receives. Different parameter requests different objects are produced. This time another design pattern Builder Pattern is returned from the factory.

Often a Builder design is used for constructing widgets (scrollbars, TextBox) where inside a builder class the details on how the widget is built.

Use of common design patters removes the burden of analyzing code designs. And in this case PageFactory says: "Iíll return a PageBuilder depending on what you pass on my parameters" hereís a portion of PageFactory

public AbstractPageBuilder constructPage(int a_i_request)

throws IOException


switch (a_i_request) {

case LINK:

return new LinkBuilder();

case HOME:

return new SimplePageBuilder("HOME");


return new SimplePageBuilder("Page Request Invalid");



public AbstractUpdateablePageBuilder constructPage(int a_i_request,String a_s_request_info,XMLPropertyManager a_xml_prop, ConnectToDB a_conn) throws IOException


if (a_i_request==FREE_FORM) {

return new FreeForm(a_s_request_info,a_xml_prop,a_conn);

} else {

return new TabularForm(a_s_request_info,a_xml_prop,a_conn);




In simple terms; transform maintenance tables(itemcode, itemtype, supplier codes.. etc) into forms. got this idea from my last employer where maintenance tables were generated in a wizard-like way. Imagine 20 maintenance pages were generated like crazy! In a few minutes they are done, just setting the field length of textboxes and setting the column labels and others are the programmers that have to do. Itís a waste of a programmers mind energy do do those routinal work. Iíll explain further. Get the column length properties in the table. And you got field length. What about validation? If itís not null then itís required. If it is a primary key itís required. If another column is a foreign key it is required. But in FreeFormís case it does not lookup into the column properties. Instead it retrieves information from an XML file (forms.xml inside the properties folder).

Now you might say: "Do not generalize!" yes if there are some custom maintenance pages just extend FreeForm and override which function should be customized.

FreeForm is a PageBuilder, meaning it generates its own page inside. Itís a subclass of AbstractUpdateablePageBuilder. So basic constitution of AbstractPageBuilder is FreeFormís constitution. AbstractUpdateablePageBuilderís method are called from RequestManager. See again above.