浏览 5017 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-04-27
public class Finance extends BaseObject { private String uniqueId; private String id; private String name; private Map attributes = new TreeMap(); //get/set property } public class Attribute extends BaseObject { private String id; private String chLabel; private String enLabel; private String type; private String value; //get/set property } 如果我要在extrmeTable中访问Finance对象中一个Attribute的字段,可以这样写: <ec:table items="dataList" var="datas" action="${ctxPath}/dataShow.html"> <ec:row highlightRow="true"> <ec:column property="id" width="5%"/> <ec:column property="attributes" width="5%"> ${datas.attributes.attr1} </ec:column> </ec:row> </ec:table> 而现在我要通过AutoGenerateColumns动态产生列: public class AutoGenDataListColsImpl implements AutoGenerateColumns { public void addColumns(TableModel model) { List beans = (List)model.getContext().getRequestAttribute("dataList"); String var = model.getTableHandler().getTable().getVar(); if (beans!=null && beans.size()>0) { Finance finObj = (Finance)beans.get(0); Map attrs = finObj.getAttributes(); Iterator colItr = attrs.keySet().iterator(); while(colItr.hasNext()) { String key = (String)colItr.next(); Attribute attr = (Attribute)attrs.get(key); Column column = new Column(model); column.setProperty("attributes"); column.setValue("${"+var+".attributes.attr1}"); column.setTitle(attr.getChLabel()); model.getColumnHandler().addAutoGenerateColumn(column); } } } } 却发现不行,返回不了字段的值,有人遇到过这样的情况吗? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-04-30
看了extremTable的源码知道了,这样setValue不行,它不能解析EL表达式。看来要实现这个功能,这样不行了。
|
|
返回顶楼 | |
发表时间:2007-05-01
ectable是通过TagUtils.evaluateExpressionAsString(...)来处理el的 你也用一下就OK了 看看ec里的tag类的相关用法就能明白了
|
|
返回顶楼 | |
发表时间:2007-05-08
public final static String evaluateExpressionAsString(String attributeName, String attribute, Tag tag, PageContext pageContext) 其中的tag参数怎么取呢? |
|
返回顶楼 | |