error tapestry using data gridsource 2

萝らか妹 提交于 2019-12-25 18:24:53

问题


Continuing tutorial I have came across an error. previous problem seems to be fixed.

tutorial says: To make use of the created CelebritySource, add the following method to the ShowAll page class:

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

Then change the source parameter of the Grid component in ShowAll.tml template:

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

Run the application. Log in to view the ShowAll page, and as soon as the table with celebrities is displayed, you should see the following output:

Preparing selection. Index from 0 to 4 Property name is: null Sorting order ascending: true Getting value for row 0 Getting value for row 1 Getting value for row 2 Getting value for row 3 Getting value for row 4

page has error:

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'.

After deleteing t:model="model" from t:grid

page has error:

An unexpected application exception has occurred.

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

Anyone out there had this problem?


回答1:


Seems the example was missing a bit of code. Try adding the following to the page ShowAll.java:

@Inject
private BeanModelSource beanModelSource;

@Inject
private Messages messages;

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

From the T5 Grid Component Ref:

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

The above should create you a default BeanModel, based on public methods and properties.



来源:https://stackoverflow.com/questions/12232909/error-tapestry-using-data-gridsource-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!