|
|
||||
| 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 碎片拼装成一个页面,它也决定信息放在整个页面的哪个位置。
|
|||