在使用appfuse Tapestry 开发过程中,遇到一个问题,就是默认生成的页面对应类中,会有一些抽象方法,获取当前table的manager,例如
public abstract class CommentList extends BasePage {
public abstract CommentManager getCommentManager();
此类的形式,但是不清楚是如何获得相关值的,经过一番研究,发现是通过使用 spring 依赖注入方式来实现的,主要就是要在该table自动生成的page页面中添加如下信息:
<page-specification class="com.zrrt.wapportal.webapp.pages.Comment">
<inject property="commentManager" type="spring" object="commentManager"/>
<!-- add test code begin-->
<inject property="commentManager" type="spring" object="commentManager"/>
<inject property="contentattributeManager" type="spring" object="contentattributeManager"/>
<inject property="contentattributetypeManager" type="spring" object="contentattributetypeManager"/>
<inject property="contentresourceManager" type="spring" object="contentresourceManager"/>
<inject property="contentresourcetypeManager" type="spring" object="contentresourcetypeManager"/>
<inject property="evaluationManager" type="spring" object="evaluationManager"/>
<inject property="gameresourceManager" type="spring" object="gameresourceManager"/>
<inject property="imageresourceManager" type="spring" object="imageresourceManager"/>
<!-- add test code end-->
<property name="message" persist="flash"/>
</page-specification>
黑体部分为自行加入的,这样在这个Comment类中就可以加入:
// CommentManager
public abstract CommentManager getCommentManager();
// ContentattributeManager
public abstract ContentattributeManager getContentattributeManager();
// ContentattributetypeManager
public abstract ContentattributetypeManager getContentattributetypeManager();
// ContentresourceManager
public abstract ContentresourceManager getContentresourceManager();
// ContentresourcetypeManager
public abstract ContentresourcetypeManager getContentresourcetypeManager();
// EvaluationManager
public abstract EvaluationManager getEvaluationManager();
// GameresourceManager
public abstract GameresourceManager getGameresourceManager();
// ImageresourceManager
public abstract ImageresourceManager getImageresourceManager();
等等多个方法,并可在运行时获取到相关表的数据,当然了,最好是创建一个单例类来管理这些manager,暂时就想到这么个方法,不知道哪位仁兄有更好的方法,还请不吝赐教!~~