Reputation: 2409
I have a checkbox:
<webuijsf:checkbox immediate="true" valueChangeListenerExpression="#{user$recentreports.selectSingleCBEvent}" id="selectCB" binding="#{user$recentreports.selectCB}" toolTip="#{msg.report_select}"/>
whose valueChangeListenerExpression method is:
List<RowKey> rowsToBeRemoved=new ArrayList();
public void selectSingleCBEvent(ValueChangeEvent event) throws Exception {
RowKey rowKey = tableRowGroup.getRowKey();
System.out.println("rowKey" + rowKey);
System.out.println("tableRowGroup.getRowKey().toString()" + tableRowGroup.getRowKey().toString());
rowsToBeRemoved.add(rowKey);
FacesContext.getCurrentInstance( ).renderResponse( );
}
I have a button that must be used for deleting rows that checkbox component is selected:
<webuijsf:button actionExpression="#{user$recentreports.deleteButton_action}" id="deleteButton" text="#{msg.report_delete_selected}"/>
whose backing bean is:
public String deleteButton_action() {
for(RowKey rowToBeRemoved:rowsToBeRemoved){
try {
System.out.println("rowToBeRemoved" + rowToBeRemoved);
GeneratedReport generatedReport = (GeneratedReport) reportList.getObject(rowToBeRemoved);
Query resultQuery = queryGeneration(generatedReport.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); // get single drop table query
entityManager.createNativeQuery(aDropTableQuery);
reportList.removeRow(rowToBeRemoved);
reportList.commitChanges();
}
generatedReportJpaController.delete(generatedReport);
reportList.commitChanges();
analyzerResultService.drop(generatedReport.getId().longValue());
} catch (Exception e) {
error("Cannot delete report with row key " + rowToBeRemoved + e);
}
}
return null;
}
output of this form is:
[#|2011-10-17T11:47:14.304+0300|INFO|glassfishv3.0|null|_ThreadID=25;_ThreadName=Thread-1;|rowKeyRowKey[0]|#]
[#|2011-10-17T11:47:14.304+0300|INFO|glassfishv3.0|null|_ThreadID=25;_ThreadName=Thread-1;|tableRowGroup.getRowKey().toString()RowKey[0]|#]
[#|2011-10-17T11:47:14.304+0300|INFO|glassfishv3.0|null|_ThreadID=25;_ThreadName=Thread-1;|rowKeyRowKey[1]|#]
[#|2011-10-17T11:47:14.304+0300|INFO|glassfishv3.0|null|_ThreadID=25;_ThreadName=Thread-1;|tableRowGroup.getRowKey().toString()RowKey[1]|#]
which means my deleteButtonAction is reached but is not performing the actions that I write (getting rowKey from rowsToBeRemoved and deleting them), I don't understand why. Back bean is request scoped does it have any relevance?
Upvotes: 0
Views: 652
Reputation: 12880
My impression is you short-circuit JSF lifecycle by calling FacesContext.getCurrentInstance( ).renderResponse( ) in selectSingleCBEvent and your actionListener is never reached.
ValueChangeListeners for immediate inputs are called in ApplyRequestValues phase. ActionListeners are called later in InvokeApplication phase. By calling renderResponse() you skip the rest of the cycle and proceed directly to RenderResponse phase.
Upvotes: 1