表不刷新
我有一个由多行报告组成的表格。与复选框值更改事件相关的后台 bean 方法是获取行 ID 并使用该 ID 填充数组 (rowsToBeRemoved)。另一种方法获取此数组并从报告列表类中删除该对象:
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);
}
代码执行良好,从报告列表中删除该对象,但之后我的表会显示一个混合报告列表。如果我刷新页面,它将按正确的顺序显示报告列表,否则不会。如果我尝试删除处于混合状态的行,它会删除报告,就好像它的顺序正确一样,从而以删除错误的报告结束。我希望我能解释一下..我做错了什么?
I have a table that consists of rows of reports. A back bean method that is tied to a check box value change event is getting the row IDs and populating an array (rowsToBeRemoved) with this IDs. Another method gets this array and removes the object from reportlist class:
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);
}
The code executes fine, removes the object from the reportlist but after that my table brings up a mixed reportlist. If I refresh the page it brings the reportlist in correct order, otherwise it doesn't. And if I try to delete a row in the mixed state it deletes the report as if it is in correct order, thus ending with deleting the wrong report. I hope I could explained.. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这与您正在寻找的内容类似: 如何从支持 bean 刷新整个 JSF 页面
这不仅仅刷新页面的一部分,而是刷新整个页面。
I think this is similar to what you're looking for: How to refresh entire JSF page from the backing bean
This doesnt just refresh one part of the page though, but the full page.