我有一个日期框
<datebox id="infrom" style ="z-index: 100000;" format="yyyy-MM-dd" value ="@bind(vm.date)"
onChange="@global-command('dataChanged', indate = infrom.value)" />
日期的默认值现在为 -1并有一个按钮搜索
<button id="searchButton" label="Search" image="/img/search.png" onClick="@command('listCars', indate = infrom.value)"/>
网格将加载昨天的数据当我选择另一天时网格将加载所选日期的数据还有我的网格
<listbox id="carListbox" height="" emptyMessage="No data found in the result" model="@bind(vm.cars)" >
<listhead>
<listheader label="Date" />
<listheader label="Actionid" />
<listheader label="Num user" />
<listheader label="Total action" />
</listhead>
<template name="model" >
<listitem>
<listcell label="@bind(each.date)"></listcell>
<listcell label ="@bind(each.action)"></listcell>
<listcell label="@bind(each.user)"></listcell>
<listcell label="@bind(each.total)"></listcell>
</listitem>
</template>
</listbox>
还有我的代码
private List<Car> cars;
public List<Car> getCars()
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(new Date()); // Now use today date.
c.add(Calendar.DATE, -1);
String output = sdf.format(c.getTime());
final StringBuilder builder = new StringBuilder("");
for (final Action action : getActions()) {
if (action.getChecked()) {
builder.append(';');
builder.append(action.getActionid());
}
}
String lstAction = builder.toString();
lstAction = lstAction.substring(1);
String[] arrAction = lstAction.split(";");
cars = carService.search(output, arrAction);
return cars;
}
@Command
@NotifyChange("cars")
public void listCars(@BindingParam("indate") Date indate){
SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd");
String date = dt1.format(indate);
final StringBuilder builder = new StringBuilder("");
for (final Action action : actions) {
if (action.getChecked()) {
builder.append(';');
builder.append(action.getActionid());
}
}
String lstAction = builder.toString();
lstAction = lstAction.substring(1);
String[] arrAction = lstAction.split(";");
cars = carService.search(date, arrAction);
//return result;
//carListbox.setModel(new ListModelList<Car>(result));
}
但是当我选择另一天时,我无法重新加载网格请给我任何方法来揉捏它们谢谢大家
为什么要绑定参数以使用 @BindingParam("indate")?
如果将日期值与此绑定:
<datebox style ="z-index: 100000;" format="yyyy-MM-dd" value ="@bind(vm.date)"
onChange="@global-command('dataChanged', indate = infrom.value)" />
所以你不能使用
String date = dt1.format(indate);
在列表汽车函数中,而不是在其中使用@BindingParam。
相反,您需要声明
private Date date;
在视图中模型,与他的getter和setter。