Vấn đề
Khi tôi cố gắng để làm tổ một phần composite trong chính nó, với một số logic để kết thúc đệ quy vô hạn tôi nhận được một ngoại lệ stack overflow. Sự hiểu biết của tôi là <c:xxx>
tags run at view build time vì vậy tôi đã không mong đợi để có một xây dựng xem vô hạn như tôi đoán đã được các trường hợp.Nested JSF Linh kiện composite dẫn đến một ngoại lệ Stack Overflow
Đây là thành phần hỗn simpleNestable.xhtml
<!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:composite="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:em="http://xmlns.jcp.org/jsf/composite/emcomp"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<h:head>
<title>This content will not be displayed</title>
</h:head>
<h:body>
<composite:interface>
<composite:attribute name="depth" required="true" type="java.lang.Integer"/>
</composite:interface>
<composite:implementation>
<c:if test="#{cc.attrs.depth lt 3}">
#{cc.attrs.depth}
#{cc.attrs.depth+1}
<em:simpleNestable depth="#{cc.attrs.depth+1}" />
</c:if>
</composite:implementation>
</h:body>
</html>
Đây là cách nó được sử dụng
<h:head>
<title>Facelet Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet name="./css/default.css"/>
<h:outputStylesheet name="./css/cssLayout.css"/>
</h:head>
<h:body>
<emcomp:simpleNestable depth="1"/>
</h:body>
Các Stack Overflow Exception
java.lang.StackOverflowError
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:2407)
at com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap.get(CompositeComponentAttributesELResolver.java:393)
at javax.el.MapELResolver.getValue(MapELResolver.java:199)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:140)
at com.sun.el.parser.AstValue.getValue(AstValue.java:204)
at com.sun.el.parser.AstPlus.getValue(AstPlus.java:60)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.faces.facelets.el.ContextualCompositeValueExpression.getValue(ContextualCompositeValueExpression.java:158)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:2407)
at com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap.get(CompositeComponentAttributesELResolver.java:393)
at javax.el.MapELResolver.getValue(MapELResolver.java:199)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:140)
at com.sun.el.parser.AstValue.getValue(AstValue.java:204)
at com.sun.el.parser.AstPlus.getValue(AstPlus.java:60)
Các Câu hỏi
Làm thế nào tôi có thể hợp tổ thành phần (hoặc tương tự) trong bản thân (đến độ sâu không được xác định trước) mà không nhận được một ngoại lệ stack overflow
Tại sao tôi muốn điều này
Tôi có dữ liệu lồng nhau tùy ý mà tôi muốn đại diện trong một collapsibleSubTable lồng nhau từ RichFaces, các lựa chọn thay thế cho cách tiếp cận của tôi rất được hoan nghênh
@BalusC Tôi không hiểu, đây không phải là vấn đề java-ee? Không phải là một phần của java-ee? –
Đó là JSF cụ thể. Q này không thú vị đối với những người dùng Java EE không sử dụng JSF. – BalusC