1
this primefaceExemple을 사용하여 treeTable을 만들고 싶습니다.Primefaces, 자식 노드 무한 포함
동적으로 설정하기 위해 객체로 반복 중입니다.
<!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:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:sec="http://www.springframework.org/security/tags">
<h:body>
<ui:composition template="/pages/theme/back/backOfficeLayout.xhtml">
<ui:define name="bo-header">
<p class="lead blog-description">Module administration.</p>
</ui:define>
<ui:define name="content">
<h:form id="form">
<h:button outcome="add" id="addModule" value="Create new module" styleClass="btn btn-primary" /><br /><br />
<p:treeTable id="treetable" value="#{moduleMB.root}" var="document">
<f:facet name="header">Document Viewer</f:facet>
<p:column style="width:32%">
<f:facet name="header">Name</f:facet>
<h:outputText value="#{document.name}" />
</p:column>
<p:column style="width:32%">
<f:facet name="header">Update date</f:facet>
<h:outputText value="#{document.size}" />
</p:column>
<p:column style="width:32%">
<f:facet name="header">Type</f:facet>
<h:outputText value="#{document.type}" />
</p:column>
<p:column style="width:4%">
<p:commandLink update=":form:documentPanel" oncomplete="PF('documentDialog').show()" title="View Detail" styleClass="ui-icon ui-icon-search">
<f:setPropertyActionListener value="#{document}"
target="#{moduleMB.selectedDocument}" />
</p:commandLink>
</p:column>
</p:treeTable>
<p:dialog id="dialog" header="Document Detail" showEffect="fade" widgetVar="documentDialog" modal="true">
<p:outputPanel id="documentPanel">
<h:panelGrid columns="2" cellpadding="5" rendered="#{not empty moduleMB.selectedDocument}">
<h:outputLabel for="name" value="Name: " />
<h:outputText id="name" value="#{moduleMB.selectedDocument.name}" style="font-weight:bold" />
<h:outputLabel for="size" value="Size: " />
<h:outputText id="size" value="#{moduleMB.selectedDocument.size}" style="font-weight:bold" />
<h:outputLabel for="type" value="Type " />
<h:outputText id="type" value="#{moduleMB.selectedDocument.type}" style="font-weight:bold" />
</h:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
뷰 결과는 다음과 같습니다 : 여기
public class ModuleMB extends GenericMB<Module,ModuleService, Long> {
@Autowired
ModuleRepository moduleRepository;
private Document selectedDocument;
public ModuleMB() {
super(Module.class);
}
@Autowired
@Override
public void setService(ModuleService service) {
this.service = service;
}
public TreeNode getRoot() {
TreeNode root = new DefaultTreeNode("root", null);
Iterable<Module> moduleList = moduleRepository.findAll();
for (Module m : moduleList) {
TreeNode modules = new DefaultTreeNode(new Document(m.getLabel(), Long.toString(m.getLastModified()), m.getClass().getName()), root);
}
for (TreeNode curModuleNode : root.getChildren()) {
System.out.println("ROWKEY : " + curModuleNode.getRowKey());
for (Module m : moduleList) {
System.out.println("MODULE LABEL : " + m.getLabel());
for (ModuleVersion mv : m.getVersions()) {
System.out.println("MV LABEL : " + mv.getLabel());
TreeNode moduleVersions = new DefaultTreeNode(new Document(mv.getLabel(), Long.toString(mv.getLastModified()), mv.getClass().getName()), curModuleNode);
}
}
}
return root;
}
public Document getSelectedDocument() {
return selectedDocument;
}
public void setSelectedDocument(Document selectedDocument) {
this.selectedDocument = selectedDocument;
}
}
내 index.xhtml 템플릿입니다 : 여기 내 콩 코드 인 IDF 시장의
- 첫 번째 모듈
- V1 (올바른)
- V2 (올바른) ,
IDF의 시장의
- 두 번째 시장
- V1이 (잘못, 두 번째 모듈은 자녀가 그나마)
- V2는 (잘못, 두 번째 모듈은 자녀가 그나마)
- 을 테스트
- V1 (잘못되었으므로 테스트 A에는 자식이 없습니다)
- V2 (잘못되었으므로 테스트 A 모듈에는 자식이 없음) 여기
(210)는 콘솔 출력 (I 때문에 많은 반복의 모든을 넣어하지 않음) : 내 모듈 버전이 각 모듈에 부착하는 이유
ROWKEY : 0
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 1
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 2
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 0
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 1
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 2
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 0
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 1
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 2
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 0
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 1
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 2
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 0
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 1
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 2
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 0
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 1
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 2
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 0
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 1
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 2
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
ROWKEY : 0
MODULE LABEL : First module of the IDF market
MV LABEL : V1
MV LABEL : V2
MODULE LABEL : Second module of the IDF market
MODULE LABEL : test A
...
나는 때문에, 이해가 안 돼요 첫 번째 모듈 만 모듈 버전을 얻습니다. 다른 두 모듈은 아닙니다!
오른쪽에있는 룹트를 클릭 할 때 moduleVersion 루프 클릭 할 때또한, 모듈 정보는 모듈 버전 정보 대신 writen됩니다 Snite
감사합니다. 이전에 당신과 같은 루프를 만들려고했지만 부모 노드가 자식 노드를 추가하기 전에 종료되지 않았다는 예외가있었습니다. 코드는 괜찮습니다. 감사합니다! – Snite