2012-09-02 57 views
0

继续tutorial我遇到了一个错误。 以前的问题似乎是fixed错误挂毯使用数据gridsource 2

教程说: 要使用所创建的CelebritySource的,添加以下方法给勾住ShowAll页面类:

public GridDataSource getCelebritySource() 
{ 
return new CelebritySource(dataSource); 
} 

然后更改ShowAll.tml模板网格组件的源参数:

<t:grid t:source="celebritySource" rowsPerPage="5" 
row="celebrity" t:model="model"> 

运行该应用程序。登录查看ShowAll页面,一旦显示名人表格,您应该看到以下输出:

准备选择。从0 索引4 属性名是:空 排序顺序递增:用于行0 获得值真 获得值在行1个 获得值用于行2 获得值用于行3 获得值4行

页面有错误:从T型= “模型”:

An unexpected application exception has occurred.

Exception assembling root component of page ShowAll: Could not convert 'model' into a component parameter binding: Exception generating conduit for expression 'model': Class org.apache.tapestry.pages.ShowAll does not contain a property (or public field) named 'model'.

delete一个吨后网格

页面有错误:

An unexpected application exception has occurred.

Render queue error in SetupRender[ShowAll:grid]: Index: 0

任何人都有这个问题吗?

回答

2

似乎这个例子缺少了一些代码。尝试添加下列到ShowAll.java页:

@Inject 
private BeanModelSource beanModelSource; 

@Inject 
private Messages messages; 

public BeanModel<Celebrity> getModel() { 
    return beanModelSource.createDisplayModel(Celebrity.class, messages); 
} 

T5 Grid Component Ref

The model used to identify the properties to be presented and the order of presentation.

上面应该创建你默认BeanModel来完完全全的基础上,公开方法和属性。

+0

改进了解决方案。 但现在它显示相同的错误,因为当我从t:grid页面删除t:model =“model”时出现错误:>出现意外的应用程序异常。在SetupRender [ShowAll:grid]中渲染队列错误:索引:0 – nkvnkv