功能和外观和fins的ecside差不多, 最大的不同是:
分页、查询等操作是 在页面中(tag)进行的,而不是在controller中进行,有些callback的味道.
这样做最大的优点在于web层代码非常简单,
在spring mvc中:
//创建FilterList(一个用于收集查询条件的类)的帮助方法,并将DataProvider(用于在列表标签中查询数据)存储在ModelMap中。
FilterList newFilterList(Class<?> entityClass, ModelMap mm){
FilterList fl = new FilterList();
DataProvider dp = new DefaultDataProvider(entityClass, this.sessionFacotry, fl);
mm.addAttribute("dataProvider", dp);
return fl;
}
@RequestMapping("/topics/index.do")
public void index(ModelMap mm){
//添加查询条件
this.newFilterList(Topic.class, mm).lt("createdAt", new Date()).desc("createdAt").join("user");
//设置mappingItem功能所需的Map
mm.addAttribute("topicTypeMap", this.getTopicTypeMap());
}
在其他框架中用HttpServletRequest替换ModelMap即可!
页面代码:
<ec:table action="${pageContext.request.contextPath}/topics/index.do"
formId="checked_docs" exportFileName="主题列表" height="200px">
<ec:column width="30" property="title" title="标题" filterType="like"/>
<ec:column width="20" property="user.name" title="作者" filterType="like"/>
<ec:column width="20" property="type" title="类型" mappingItem="${topicTypeMap }" filterType="="/>
<ec:column width="30" property="createdAt" title="发表时间" sortable="true" filterType="btw"/>
</ec:table>