我正在使用icefaces 3.0.0 版,并且我正在使用 ace dataTable 组件,如下所示:
1- Jsf代码:
<ace:dataTable id="cityTable"
value="#{weatherBean.cities}"
var="city"
paginator="true"
paginatorPosition="bottom"
rendered="#{weatherBean.cities.size()>0}"
rows="#{weatherBean.pageSize}"
style="width: 950px;">
<ace:column id="country" headerText="Country" sortBy="#{city.countryName}"
filterBy="#{city.countryName}" filterMatchMode="contains">
<h:outputText id="countryNameCell" value="#{city.countryName}"/>
</ace:column>
<ace:column id="action" headerText="Actions">
<sec:authorize access="hasRole('perm_edit_city')">
<pretty:link mappingId="editcity">
<f:param value="#{city.id}" />
<h:graphicImage url="/resources/images/edit.png" style="border: 0px;"></h:graphicImage>
</pretty:link>
</sec:authorize>
<b/>
<sec:authorize access="hasRole('perm_delete_city')">
<h:commandButton id="deleteR" image="/resources/images/delete.png"
action="#{weatherBean.deleteCity(city.id)}"
onclick="var r=confirm('Are you sure you want to delete #{city.name} ?');if (r==true){}else{return false; }"
>
</h:commandButton>
</sec:authorize>
</ace:column>
</ace:dataTable>
2-支持bean代码:
@Component("weatherBean")
@Scope("view")
public class WeatherBean {
private List<City> cities;
@Autowired
private CityService cityService;
@PostConstruct
public void init() {
cities = cityService.getAllCity();
}
public void deleteCity(Long cityId) {
log.debug("Delete deleteCity : " + cityId);
cityService.deleteCity(cityService.getCityById(cityId));
}
}
问题:
- 默认情况下,datatable 显示从 id 1 到 id 20 的城市。
- 例如,如果我按名称进行搜索,并且搜索返回的结果为 id 100 到 id 120,并且我尝试在任何搜索结果上调用 delete 方法,则会在旧 id 上调用 delete 方法>>
action="#{weatherBean.deleteCity(city.id)}"
未city.id
更新搜索后。
请指教,谢谢。