关于appfuse里自动生成的tablemanager的使用问题

 在使用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,暂时就想到这么个方法,不知道哪位仁兄有更好的方法,还请不吝赐教!~~

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值