1.0          Other languages
 
 

3.3.6 Page layout

 
 

Most web projects or web application products, need to have uniform appearance. For example, herder same in all pages. Or page footer, or navigation menu.

But there is some special case. Login page, normally, do not have navigation menu in most applications.

VelocityWeb give us a way to define layout at "page level". Which means, each page can define it's own layout, in the relative dispatcher class.

Another easy way, is to define page layout at dispatcher group. This can easily make all dispatchers in the group have same layout.

For example, if we define layout at ProductDispatcherGroup, then all dispatchers of product will have same layout.

public class ProductDispatcherGroup extends DispatcherGroup {
    static {
        DispatcherTreeManager.addParentChildrenRelationship(
                ProductDispatcherGroup.class, ViewCategoryDispatcher.class);
        DispatcherTreeManager.addParentChildrenRelationship(
                ProductDispatcherGroup.class, ViewProductDispatcher.class);
        DispatcherTreeManager.addParentChildrenRelationship(
                ProductDispatcherGroup.class, ViewProductItemDispatcher.class);
    }

    public ProductDispatcherGroup() {
        this.setPageLayout(new VPetStorePageLayout());
    }

    public String getUrlId() {
        return "product";
    }

}
	  

And the page layout will be done in VPetStorePageLayout, which decide how to combile different HTML pieces into one page. It will also decide where the content will be showed in the whole page window.