原创作者: passren   阅读:1633次   评论:0条   更新时间:2011-05-26    
我的系统中有这样两个JavaBean:

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 条 请登录后发表评论

发表评论

您还没有登录,请您登录后再发表评论

文章信息

  • fins在2007-04-27创建
  • fins在2011-05-26更新
Global site tag (gtag.js) - Google Analytics