使用時RF4的方式來構建豐富的我遇到了一個奇怪的例外奇怪的異常使用C時:的foreach,豐富的:列,下面是一個例子來重現問題:列,複合材料構件
page.xhtml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:my="http://java.sun.com/jsf/composite/my"
xmlns:rich="http://richfaces.org/rich">
<h:head/>
<h:body>
<f:view>
<h:form>
<a4j:commandButton value="2 columns" action="#{testBean.creat2Headers()}" render="@form" />
<a4j:commandButton value="5 columns" action="#{testBean.creat5Headers()}" render="@form" />
<a4j:outputPanel id="patientMain" layout="block">
<rich:dataTable id="produitTable" var="produit" value="#{testBean.table}">
<c:forEach items="#{testBean.header}" var="header">
<rich:column>
<my:input valueSelected="#{testBean.testValue}" />
</rich:column>
</c:forEach>
</rich:dataTable>
test
<my:input valueSelected="#{testBean.testValue}" />
</a4j:outputPanel>
</h:form>
</f:view>
input.xhml用於複合部件,用於輸入的ID必須在那裏。
<?xml version="1.0" encoding="ISO-8859-1" ?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html" xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="valueSelected" required="true"/>
</composite:interface>
<composite:implementation>
<h:inputText value="#{cc.attrs.valueSelected}" id="input"/>
</composite:implementation>
</html>
Java代碼TestBean.java
@ManagedBean
@ViewScoped
public class TestBean implements Serializable{
private List<String> table = new ArrayList<String>();
private List<String> header=new ArrayList<String>();
private Integer testValue=0;
public TestBean(){
logger.info("bean created");
this.table.add("ligne1");
this.header.add("header1");
this.header.add("header2");
}
public void creat2Headers(){
this.header.clear();
this.header.add("header1");
this.header.add("header2");
}
public void creat5Headers(){
this.header.clear();
this.header.add("header1");
this.header.add("header2");
this.header.add("header3");
this.header.add("header4");
this.header.add("header5");
}
public List<String> getTable() {
return this.table;
}
public void setTable(List<String> _table) {
this.table = _table;
}
public List<String> getHeader() {
return this.header;
}
public void setHeader(List<String> _header) {
this.header = _header;
}
public Integer getTestValue() {
return this.testValue;
}
public void setTestValue(Integer _testValue) {
this.testValue = _testValue;
}
}
當你點擊該按鈕creat2columns,然後點擊creat5columns,你得到的異常
09/10 14:21:44,638 Grave [javax.enterprise.resource.webcontainer.jsf.application] JSF1007 : ID de composant j_idt4-j_idt88-input is double in the view.
09/10 14:21:44,639 Grave [javax.enterprise.resource.webcontainer.jsf.application] +id: j_id1
type: [email protected]
+id: javax_faces_location_HEAD
type: [email protected]
+id: __rf_skinning_resource
type: [email protected]
+id: j_id10
type: [email protected]
+id: j_id11
type: [email protected]
+id: j_id12
type: [email protected]
+id: j_id13
type: [email protected]
+id: j_idt1
type: <html xmlns="http://www.w3.org/1999/xhtml">
+id: j_idt2
type: [email protected]
+id: j_idt70
type: [email protected]
+id: j_idt4
type: [email protected]
+id: j_idt71
type: [email protected]
+id: j_idt72
type: [email protected]
+id: patientMain
type: [email protected]
+id: produitTable
type: [email protected]
+id: j_idt84
type: [email protected]
+id: j_idt85
type: [email protected]
+id: j_id3
type: [email protected]
+id: input
type: [email protected]
+id: j_idt86
type: [email protected]
+id: j_idt87
type: [email protected]
+id: j_id3
type: [email protected]
+id: input
type: [email protected]
+id: j_idt7
type:
tt
+id: j_idt88
type: [email protected]
+id: j_id3
type: [email protected]
+id: input <===============
type: [email protected]
+id: input <===============
type: [email protected]
+id: j_idt63
type:
</html>
請幫我
在此先感謝
用h:datatable和h:列替換rich:column和rich:datatable仍然有同樣的問題。 – liumin