原创作者: passren
阅读:1689次
评论:0条
更新时间:2011-05-26
我的系统中有这样两个JavaBean:
如果我要在extrmeTable中访问Finance对象中一个Attribute的字段,可以这样写:
而现在我要通过AutoGenerateColumns动态产生列:
却发现不行,返回不了字段的值,有人遇到过这样的情况吗?
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); } } } }
却发现不行,返回不了字段的值,有人遇到过这样的情况吗?
评论 共 0 条 请登录后发表评论