« Return to Thread: Tables and non-POJO lists

Tables and non-POJO lists

by Brawn Do :: Rate this Message:

Reply to Author | View in Thread

Hi,

I've got a handle on dealing with POJO beans within my tables, but am unclear how to handle "simple" lists of primitive elements like strings. I  must be missing the boat on this.  With the code below I'm attempting to simply display the name "foo", but instead end up with a com.sun.webui.jsf.faces.DataProviderELResolver$ValueData toString()'d  Can anyone lend a hand (code below)?  Similar code works fine with POJO lists; e.g., where the name is a getter on a bean  #{mybeanwithanamegetter.value.name}

Thanks!

Table table = new Table();
table.setId("tbl");
TableRowGroup rowGroup = new TableRowGroup();
rowGroup.setId("rowGroup");
rowGroup.setSourceVar("name");
List<String> names = new LinkedList<String>();
names.add("foo");
ListDataProvider provider = new ListDataProvider (names);
rowGroup.setSourceData(provider);
TableColumn column = new TableColumn();
column.setId("col");
column.setHeaderText("Value");
StaticText nameText = new StaticText();
nameText.setId("nameText");
FacesContext context = FacesContext.getCurrentInstance();
nameText.setValueExpression("value",
  context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(), "#{name.value}",String.class)

column.getChildren().add(nameText);
rowGroup.getChildren().add(column);
table.getChildren().add(rowGroup);

 « Return to Thread: Tables and non-POJO lists

LightInTheBox - Buy quality products at wholesale price!