private static void showPage(String custId, String errMsg) { // Obviously this is inefficient -- the list of customer and products never changes, // so we could cache it. List<Customer> customers = Customer.find("order by name").fetch(); List<Product> products = Product.find("order by name").fetch(); Customer currentCustomer; if (custId == null || custId.trim().length() == 0) currentCustomer = customers.get(0); else currentCustomer = Customer.findById(new Long(custId)); renderTemplate("Application/index.html", customers, currentCustomer, products, errMsg); }