Issue 124: pure String will not be parsed properly ?
Status:  WontFix
Owner: ----
Closed:  Jul 2008
Reported by wutong...@gmail.com, Jul 25, 2008
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
oh I forgot to mention that 

itemValue = PropertyUtils.getProperty(item, property);

will throw the nosuchmethod exception because apache beanutil will consider 
the "item" as a bean and try to locate the getter method "getCol()" in class "item"

that's why we can not pass a list of String to generate table 
Jul 25, 2008
#2 bgo...@e1b.org
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
#3 extremec...@gmail.com
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