Tapestry - 页面加载之二

1.      页面创建

a)        说明:页面创建主要是指当页面文件被找到以后,如何根据声明中的信息,初始化页面类及其控件树。

b)        流程图:

 

c)        代码:

                      i.              IPageLoader.loadPage()

public IPage loadPage(String name, INamespace namespace, IRequestCycle cycle,

           IComponentSpecification specification){

              IPage page = null;

_count = 0;

_depth = 0;

_maxDepth = 0;

_locale = _threadLocale.getLocale();

try{

page = instantiatePage(name, namespace, specification);

page.attach(cycle.getEngine(), cycle);

constructComponent(cycle, page, page, specification, namespace);

 

……

page.firePageAttached();

}finally{

_locale = null;

_inheritedBindingQueue.clear();

}

return page;

}

 

注:上述代码描述了页面创建过程的基本骨架,首先是对页面类进行实例化,然后注入所需要的上下文信息,然后就是构造页面的整棵控件树。最后是发出通知。

 

                   ii.              ComponentConstructorFactory.getComponentCoustructor()

    public ComponentConstructor getComponentConstructor(IComponentSpecification specification,

 String className){

synchronized (specification){

ComponentConstructor result = (ComponentConstructor) _cachedConstructors.

get(specification);

if (result == null){

Class baseClass = _classResolver.findClass(className);              EnhancementOperationImpl eo = new EnhancementOperationImpl(_classResolver,

 specification, baseClass, _classFactory, _log);         _chain.performEnhancement(eo, specification);

result = eo.getConstructor();

 

// TODO: This should be optional to work around that IBM JVM bug.

_validator.validate(baseClass, result.getComponentClass(), specification);

_cachedConstructors.put(specification, result);

}

return result;

}

}

 

注:上述代码解释了为什么在得到了页面类以后,还要专门通过ComponentConstructorFactory来获得构造

函数,然后实例化。由于我们声明的页面类可能是一些抽象类,它包含了一些抽象的属性操作方法,这些方

法的实现就是在这一步完成的。

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值