| Issue 124: | pure String will not be parsed properly ? | |
| 1 person starred this issue and may be notified of changes. | Back to list |
org.jmesa.util.ItemUtils.getItemValue() does not work on String Item ?
If we code as followed ,the table would not render well
---------------------------------------------------------
ArrayList<String> items=new ArrayList<String>();
items.add("1");
items.add("2");
items.add("3");
TableFacade tableFacade = createTableFacade(id, request);
tableFacade.setColumnProperties("col");
tableFacade.setItems(items);
tableFacade.getTable();
String html = tableFacade.render();
request.setAttribute("presidents", html);
-------------------------------------------------------
I revised the class org.jmesa.util.ItemUtils and changed the following
code around line 66
//--------------
} else {
itemValue = PropertyUtils.getProperty(item, property);
}
//--------------
to
//--------------
} else if(item instanceof String){
itemValue = item.toString();
}else{
itemValue = PropertyUtils.getProperty(item, property);
}
//---------------
it works well again and prints table properly like
Col
----
1
2
3
Jul 25, 2008
#1
wutong...@gmail.com
Jul 25, 2008
I think at a more correct use of the API would be:
ArrayList<Map> items=new ArrayList<Map>();
Map bean1 = new HashMap();
Map bean2 = new HashMap();
Map bean3 = new HashMap();
bean1.set("col", "1");
bean2.set("col", "2");
bean3.set("col", "3");
items.add(bean1);
items.add(bean2);
items.add(bean3);
TableFacade tableFacade = createTableFacade(id, request);
tableFacade.setColumnProperties("col");
tableFacade.setItems(items);
tableFacade.getTable();
The table is meant to work by processing a Collection of beans remember. Right?
Jul 26, 2008
I agree that it is not an appropriate use of the API. I was tempted to still put this in anyway, but once I did I saw that other parts of the api, like the filtering and sorting, do not work. This is because working with a list of strings is not the same as working with a list of beans (or maps). Thank you for the post though. It was interesting to think about.
Status:
WontFix
|