Source code for /src/java/com/coolshare/springapp/Constant.java

// =====================================================================//
// Author: Mark Qian <markqian@hotmail.com>                             //
// WWW: http://www.coolshare.com/                                       //
// Copyright (c) 2006, Mark Qian                                        //
//                                                                      //
// You must contact Mark Qian to get a permission of use                //
// in case you want to make any use of the codes except viewing it     //
// on Mark's site.                                                      //
//======================================================================//
package com.coolshare.springapp;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;

import com.coolshare.springapp.web.TileInfo;
import com.coolshare.springapp.web.FieldInfo;

public class Constant {

	// public static int sessionTimeout = 2;
	public static Map BEAN_MAP = new HashMap();
	static {
		/***********************************************************************
		 * 
		 * Ideally, content of this section should be read from configuration
		 * files when application is loaded.
		 * 
		 * A "Tile" concept is introduced here. A Tile represents a physical
		 * piece of screen and appear as a micro MVC:
		 * 
		 *    Model - the bean linked by field modeClassName field 
		 *                 in TileController 
		 *    View - the jsp linked by field viewName field in TileController 
		 *    
		 *    Controller - TileController.
		 * 
		 **********************************************************************/
		TileInfo beanInfo = new TileInfo();
		beanInfo.setModelClassName("com.coolshare.springapp.bus.Bamboo");
		beanInfo.setViewName("form");
		List fields = new ArrayList();
		fields.add(new FieldInfo("id", 128, 0, 20, "hidden", "Id"));
		beanInfo.setHiddenFields(fields);
		fields = new ArrayList();
		fields.add(new FieldInfo("name", 128, 0, 20, "text", "Name"));
		fields.add(new FieldInfo("price", 128, 0, 20, "text", "Price"));
		fields.add(new FieldInfo("size", 128, 0, 20, "text", "Size"));
		fields.add(new FieldInfo("quantity", 128, 0, 20, "text", "Quantity"));
		fields.add(new FieldInfo("height", 128, 0, 20, "text", "Height"));
		fields.add(new FieldInfo("light", 128, 0, 20, "text", "Light"));
		beanInfo.setDisplayFields(fields);
		BEAN_MAP.put("Bamboo", beanInfo);

		beanInfo = new TileInfo();
		beanInfo.setModelClassName("com.coolshare.springapp.bus.Source");
		beanInfo.setViewName("form");
		fields = new ArrayList();
		fields.add(new FieldInfo("name", 128, 0, 20, "hidden", "Name"));
		beanInfo.setHiddenFields(fields);
		fields = new ArrayList();
		fields.add(new FieldInfo("id", 128, 0, 20, "select", "Name", "Sources"));
		fields.add(new FieldInfo("address", 128, 0, 20, "text", "Address"));
		fields.add(new FieldInfo("phone", 128, 0, 20, "text", "Phone"));
		fields.add(new FieldInfo("discount", 128, 0, 20, "text", "Discount"));
		beanInfo.setDisplayFields(fields);
		BEAN_MAP.put("Source", beanInfo);

	}

}