这是我的代码:
<p:panel id="compPanelId" header="COMPUTERS" styleClass="compPanel">
<h:form id="availableCompForm">
<div style="text-align: center; margin-bottom: 8px;">
<p:commandLink id="addCompBtn" value="Add" actionListener="#{coltsysLab.addComputer(event)}" style="height: 30px; font-size: 13px; margin-left: 10px;" update="availableCompForm"/>
</div>
<p:dataGrid id="availableComputers" value="#{coltsysLab.computer}" var="computer" columns="3" emptyMessage="No Computers Added Yet">
<p:column>
<p:graphicImage id="computer" value="http://localhost:8080/COLTSysResources/resources/images/#{computer.pic}" styleClass="computerImage"/>
<p:draggable for="computer" revert="true" scope="#{computer.status}" stack=".computerImage"/>
</p:column>
</p:dataGrid>
</h:form>
</p:panel>
单击添加命令链接后,数据网格不会更新
方法 addComputer 中的托管 bean 代码是:
try (Connection conn = dataSource.getConnection()) {
ColtsysDAO coltsysDAO = new ColtsysDAO(conn);
coltsysDAO.addComputer(currentComputer, labId);
} catch (Exception e) {
e.printStackTrace(System.err);
}