1.0          Other languages

3.3.1 Normal leaf dispatcher


In most case, one leaf dispatcher represent one web request. And also we can call it a function point. The terms "normal leaf dispatcher" in VelocityWeb means dispatchers without failure. For example, a search page, or a view page.

In normal leaf dispatcher, we get user input data from HTTP request object, and call business service functions, and then put result data into WebAppContext. The VelocityWeb framework will then use it to show result page.

Here is a sample:

public class ViewProductDispatcher extends QueryDispatcher {
        public boolean process(HttpServletRequest request, WebAppContext context,
                Controller controller) throws Exception {

            this.setPageTitle("View product");

            String productId = request.getParameter("product_id");

            ProductService service = new ProductService(context);
            String productName = service.getProductNameById(productId);
            List productItemList = service.getProductItemsById(productId);

            context.put("product_name", productName);
            context.put("product_item_list", productItemList);
            context.put("view_product_item_url", DispatcherTreeManager.getUrl(ViewProductItemDispatcher.class));
            context.put("add_cart_item_url", DispatcherTreeManager.getUrl(AddItemToCartDispatcher.class));

            return true;

        public String getUrlId() {
            return "view_product";