|
||||
1.0 其他語言 |
||||
3.3.6 網頁布局 |
||||
|
大多數網路專案或者產品,需要有一個統一的外觀。比如,所有頁面有同樣的標題,或者頁腳,或者導航菜單。
也有特例。登錄頁面通常不需要導航菜單。 VelocityWeb 給出了一種在頁面上定義布局的方法。這意味著,每個頁面可以在相應的分發器處理類中,定義自己的布局。 另一個簡便的方法,是在分發器組上定義布局。這可以輕松地讓組內所有分發器都擁有同樣的布局。 舉例來說,如果我們在 ProductDispatcherGroup 上定義頁面布局,那麼所有產品相關的分發器類都將有同樣的布局。 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"; } } 頁面布局會在 VPetStorePageLayout 中完成。它將不同的 HTML 碎片拼裝成一個頁面,它也決定資訊放在整個頁面的哪個位置。
|
|||