selectAll
当我单击复选框时,从 bean调用 Java 方法的适当方法是什么?
<f:facet name="header">
<h:selectBooleanCheckbox binding="#{bean.selectAll}" onclick="highlight(this)" class="checkall"/>
</f:facet>
binding
不管用。我只想在这个 Java 方法中执行代码。
编辑
private HashMap<String, Boolean> selected = new HashMap<>();
public void selectAll() throws Exception {
String SqlStatement = null;
if (ds == null) {
throw new SQLException();
}
Connection conn = ds.getConnection();
if (conn == null) {
throw new SQLException();
}
SqlStatement = "SELECT ID FROM ACTIVESESSIONSLOG";
PreparedStatement ps = null;
ResultSet resultSet = null;
int count = 0;
try {
conn.setAutoCommit(false);
boolean committed = false;
try {
ps = conn.prepareStatement(SqlStatement);
resultSet = ps.executeQuery();
selected.clear();
while (resultSet.next()) {
selected.put(resultSet.getString("ID"), true);
}
/*
for (Map.Entry<String, Boolean> entry : selectedIds.entrySet()) {
entry.setValue(true);
}
*/ conn.commit();
committed = true;
} finally {
if (!committed) {
conn.rollback();
}
}
} finally {
ps.close();
conn.close();
}
}