我有一个由多行报告组成的表。与复选框值更改事件关联的后bean方法是获取行ID并使用此ID填充数组(rowsToBeRemoved)。另一种方法获取此数组并从reportlist类中删除该对象:
ObjectListDataProvider reportList = new ObjectListDataProvider();
List<RowKey> rowsToBeRemoved=new ArrayList();
Integer rowsToBeRemovedIndex = 0;
for(RowKey rowToBeRemoved:rowsToBeRemoved){
try {
System.out.println("rowToBeRemoved.toString()" + rowToBeRemoved.toString()); // outputs: rowToBeRemoved.toString()RowKey[0]
Report report = (Report) reportList.getObject(rowToBeRemoved);
System.out.println("report.getId()" + report.getId()); //outputs: report.getId()199|
Query resultQuery = queryGeneration(report.getId());
List<String> dropTableQueries = resultQuery.getResultList(); // generated the queries to drop r tables
for(int i=0; i<dropTableQueries.size(); i++){
String aDropTableQuery;
aDropTableQuery = dropTableQueries.get(i);
System.out.println("adroptableuery" + aDropTableQuery);// get single drop table query. outputs adroptableueryDROP TABLE r_199_0
entityManager.createNativeQuery(aDropTableQuery);
System.out.println("entitymanager dropTableQueries is invoked");//OK
reportList.removeObject(rowToBeRemoved);
System.out.println("removeObject");//OK
if (reportList.isRemoved(rowToBeRemoved)){
System.out.println("object removed");//OK
}
reportList.commitChanges();
System.out.println("commitchanges");//OK
}
reportJpaController.delete(report);
reportList.removeRow(rowToBeRemoved);
reportList.commitChanges();
analyzerResultService.drop(report.getId().longValue());
//rowsToBeRemoved.remove(rowsToBeRemovedIndex);
} catch (Exception e) {
error("Cannot delete report with row key " + rowToBeRemoved + e);
}
代码执行正常,从报告列表中删除对象,但之后我的表会显示一个混合的报告列表。如果我刷新页面,它会以正确的顺序显示报告列表,否则它不会。如果我尝试删除混合状态中的行,它会删除报告,就好像它的顺序正确一样,从而删除错误的报告。我希望我能解释一下......我做错了什么?
答案 0 :(得分:2)
我认为这与您所寻找的类似:How to refresh entire JSF page from the backing bean
这不仅仅是刷新页面的一部分,而是整页。