안녕하세요, 나는이 레코드를 삭제하는 작업 버튼이 포함 된 데이터 테이블의 열을 사용하고ConfirmDialog는 Primefaces
에 페이지 매김에서 DataTable을 방지 할 수 있습니다. 작업 버튼을 클릭하면 사용자가 레코드를 취소하거나 삭제할 수있는 확인 대화 상자가 표시됩니다. 레코드가 삭제되면 페이지 매김이 더 이상 작동하지 않습니다. 나는 PF 4.0이 문제를 재현하고 또한 Google 코드 PF에서 실제로 스냅 샷 5. 여기에 재현 할 수있는 아주 쉬운 예입니다 수 있습니다
import java.io.Serializable;
public class Entity implements Serializable {
private static final long serialVersionUID = 4544407140706106480L;
long id;
Entity(long id) {
this.id = id;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Override
public boolean equals(Object o) {
if (id != ((Entity)o).id) return false;
return true;
}
@Override
public int hashCode() {
return (int) (id^(id >>> 32));
}
}
Entity.java
CategoryController.java
@Named
@ViewScoped
public class CategoryController {
private Entity category;
private List<Entity> categories;
public CategoryController() {
categories = new ArrayList<>();
for (int i = 0; i < 100; i++) {
Entity newTest = new Entity(i);
categories.add(newTest);
}
}
public void removeCategory(){
categories.remove(category);
}
public Entity getCategory() {
return category;
}
public void setCategory(Entity category) {
this.category = category;
}
public List<Entity> getCategories() {
return categories;
}
public void setCategories(List<Entity> categories) {
this.categories = categories;
}
}
text.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<f:view>
<h:form id="form">
<p:panel header="#{langRes['setupCategories.pageTitle']}" style="height: 540px;" id="categoryTablePanel">
<!-- category table -->
<p:dataTable value="#{categoryController.categories}" var="category"
rows="10" id="categoryTable" emptyMessage="#{langRes['setupCategories.emptyTable']}"
paginator="true" paginatorPosition="top">
<!-- category id column -->
<p:column headerText="#{langRes['setupCategories.idEntry']}" id="idColumn" width="90%">
<p:outputLabel id="categoryId" value="#{category.id}"/>
</p:column>
<p:column headerText="#{langRes['setupCategories.idEntry']}" id="editColumn" width="10%">
<p:commandButton value="Delete" oncomplete="PF('confirmDialog').show()">
<f:setPropertyActionListener value="#{category}" target="#{categoryController.category}"/>
</p:commandButton>
</p:column>
</p:dataTable>
</p:panel>
<p:confirmDialog global="true" widgetVar="confirmDialog" id="confirmationDialog">
<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"
action="#{categoryController.removeCategory}"
update=":setupCategoryForm:categoryTable"
onclick="PF('confirmDialog').hide();"/>
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
</p:confirmDialog>
</h:form>
</f:view>
</h:body>
</html>
내가 뭔가 잘못하고 AM 또는이 버그? 도와 주셔서 미리 감사드립니다.
ViewScoped에서 CDI 주석 또는 JSF를 사용하고 있습니까? @ javax.faces.view 또는 @ javax.faces.bean? – perissf
CDI Bean @ javax.faces.view – VWeber