比如,在Goods类中有一个goodsList存放了当前的所有商品,页面的代码为:
js 代码
Goods类如下:
java 代码
publicclassGoods{
....
privateDateModelgoodsList;
...
publicDataModelgetGoodsList(){
if(goodsList==null){
goodsList=newDataModel();
}
goodsList.setWrappedData(getRealGoodsList());//这里通过Service层或者Dao层访问到数据库
retrungoodsList;
}
publicStringselect(){
GoodsselectedGoods=(Goods)goodsList.getRowData();
setSelectedGoods(selectedGoods);
return"success";
}