각 행의 편집 및 삭제 명령 단추를 포함하는 1 개의 데이터 테이블이 있습니다. 삭제 버튼은 클릭 대화 상자에 확인 대화 상자를 표시하고 actionListener에 의해 currentObject 변수가 동일한 행에 속한 객체로 설정됩니다.Primefaces : confirmDialog의 commandButton이 동일한 형식의 datatable을 업데이트 할 수 없습니다.
확인 대화 상자에서 예는 명령 단추이기도하며 bean의 delete (object) 메소드를 호출합니다.
모두 정상적으로 작동합니다. 삭제 기능은 다음과 같습니다 :
public void delete(ActionEvent actionEvent) {
categoryRepository.delete(currentCategory);
currentCategory = new Category();
categoryList = categoryRepository.findAll();
}
내가 삭제 후 데이터 테이블을 업데이트합니다. 그러나 datatable에서는 업데이트가 작동하지 않습니다. @form 만 업데이트 할 수 있지만 이번에는 페이지의 모든 내용이 비활성화되고 아무 것도 선택할 수 없습니다. 버그가 될 수 있습니다.
<h:form id="categoryForm">
<p:commandButton id="addCategoryButton" value="New"
onclick="categoryDialog.show();" type="button" />
<p:dataTable var="cat" value="#{categoryBean.categoryList}"
rowKey="#{cat.id}" paginator="true" rows="10"
selection="#{categoryBean.selectedCategories}" id="categoryTable"
widgetVar="categoryTable">
<f:facet name="header">
Category List
</f:facet>
<p:column selectionMode="multiple" />
<p:column headerText="Name" sortBy="#{cat.name}"
filterBy="#{cat.name}" id="name">
#{cat.name[categoryBean.currentLocale.language]}
</p:column>
<p:column headerText="Sort Order" sortBy="#{cat.sortOrder}"
filterBy="#{cat.sortOrder}" id="sortOrder">
#{cat.sortOrder}
</p:column>
<p:column headerText="Actions" id="actions">
<h:commandButton action="#{categoryBean.edit(cat)}" value="Edit" />
<h:commandButton value="Delete"
onclick="deleteConfirmation.show()" type="button">
<f:setPropertyActionListener value="#{cat}"
target="#{categoryBean.currentCategory}" />
</h:commandButton>
</p:column>
</p:dataTable>
<p:confirmDialog id="deleteConfirmDialog" message="Are you sure?"
header="Initiating destroy process" severity="alert"
widgetVar="deleteConfirmation">
<p:commandButton id="confirm" value="Yes Sure"
update=":categoryForm:categoryTable"
oncomplete="deleteConfirmation.hide()"
actionListener="#{categoryBean.delete}" />
<p:commandButton id="decline" value="Not Yet"
onclick="deleteConfirmation.hide()" type="button" />
</p:confirmDialog>
<p:dialog id="categoryDialog" header="Category Detail"
widgetVar="categoryDialog" resizable="false" style="width:90%;"
showEffect="explode" hideEffect="explode">
<p:panel id="panel" header="Edit Category"
style="margin-bottom:10px;">
<p:messages id="messages" />
<h:panelGrid columns="3">
<h:outputLabel for="nameTabView" value="Name: " />
<p:tabView id="nameTabView">
<c:forEach var="locale" items="#{categoryBean.userLocales}">
<p:tab title="#{locale.displayLanguage}">
<h:panelGrid columns="2" cellpadding="10">
<h:inputText
value="#{categoryBean.currentCategory.name[locale.language]}" />
</h:panelGrid>
</p:tab>
</c:forEach>
</p:tabView>
</h:panelGrid>
<p:commandButton id="saveCategoryButton" value="Save"
oncomplete="categoryDialog.hide()"
actionListener="#{categoryBean.save}"
update="categoryTable, categoryDialog" />
</p:panel>
</p:dialog>
</h:form>
facelet 코드를 제시해주십시오 주셔서 감사합니다. –
업데이트를 확인하십시오. – Burak