You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by 王文楠 <wq...@gmail.com> on 2007/05/02 03:55:01 UTC
how to construct an instance of BasicTableModelWrap to render a Tableview
I get resultset base on JdbcTemplate in spring
here is my sourcecode
////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class JdbcPageTableModel implements IBasicTableModel {
..........
public Iterator getCurrentPageRows(int nFirst, int nPageSize,
ITableColumn arg2,
boolean arg3) {
List list = new JdbcTemplate(dataSource).queryForList("select
login_name,password from user_info ");
for(int i=0;i<list.size();i++){
Map map = (Map)list.get(i);
System.out.println("============"+map.get("login_name"));
}
return list.iterator();
}
....................
}
public abstract class StockDetail extends BasePage{
................................
public ITableModel getMyTableModel(){
Object[] columns =
{
"user_name","user name","user_name",new Boolean(false)
,"password","password","password",new Boolean(false)
};
ExpressionTableColumnModel columnModel = new
ExpressionTableColumnModel(columns,new ExpressionEvaluatorImpl());
return new
BasicTableModelWrap(getJdbcPageTableModel(),columnModel);
}
...........................................
}
StockDetail.html
<span jwcid="tableView@Contrib:TableView"
tableModel="ognl:myTableModel"
pageSize="ognl:10">
<table width="800" border="1">
<tr>
<td height="24" bgcolor="#FCA632" align="center"
jwcid="@Contrib:TableColumns"></td>
</tr>
<tr jwcid="tableRows@Contrib:TableRows">
<td bgcolor="#FFF1E1" height="24" align="center"
jwcid="@Contrib:TableValues"> </td>
</tr>
</table>
<table width ="100%"><tr><td align="center">
<span jwcid="@Contrib:TableFormPages" pagesDisplayed="ognl:10"/>
</td></tr></table>
</span>
///////////////////////////////////////////////////////////////////////////////////
the system can print out
"=============Green"
"==============John"
but the page StockDetail just display the title row of the table and other
rows with no content
the system print errors like this:
ERROR org.apache.tapestry.contrib.table.model.ognl.OgnlTableColumnEvaluator
- Cannot use column expression 'password' in row
java.lang.NullPointerException
at org.apache.tapestry.services.impl.ExpressionEvaluatorImpl.read(
ExpressionEvaluatorImpl.java:82)
at
org.apache.tapestry.contrib.table.model.ognl.OgnlTableColumnEvaluator.getColumnValue
(OgnlTableColumnEvaluator.java:56)
at
org.apache.tapestry.contrib.table.model.simple.SimpleTableColumn.getColumnValue
(SimpleTableColumn.java:208
what is my wrong