2

我在使用 RF4 方式构建rich:columns 时遇到了一个奇怪的异常,这里有一个重现问题的示例:

页面.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: javax.faces.component.UIViewRoot@1aa3683
  +id: javax_faces_location_HEAD
   type: com.sun.faces.component.ComponentResourceContainer@4720c8
    +id: __rf_skinning_resource
     type: javax.faces.component.UIOutput@1b9692f
    +id: j_id10
     type: javax.faces.component.UIOutput@1a8b79a
    +id: j_id11
     type: javax.faces.component.UIOutput@1adf8ee
    +id: j_id12
     type: javax.faces.component.UIOutput@b1efde
    +id: j_id13
     type: javax.faces.component.UIOutput@1fae583
  +id: j_idt1
   type: <html xmlns="http://www.w3.org/1999/xhtml">
  +id: j_idt2
   type: javax.faces.component.UIOutput@1e0e0a5
  +id: j_idt70
   type: javax.faces.component.html.HtmlBody@bc9373
    +id: j_idt4
     type: javax.faces.component.html.HtmlForm@7494a2
      +id: j_idt71
       type: org.richfaces.component.UICommandButton@1ca5783
      +id: j_idt72
       type: org.richfaces.component.UICommandButton@1377f4e
      +id: patientMain
       type: org.richfaces.component.UIOutputPanel@86db88
        +id: produitTable
         type: org.richfaces.component.UIDataTable@1b6d69b
          +id: j_idt84
           type: org.richfaces.component.UIColumn@c38e48
            +id: j_idt85
             type: javax.faces.component.UINamingContainer@b23d43
              +id: j_id3
               type: javax.faces.component.UIPanel@f207c1
                +id: input
                 type: javax.faces.component.html.HtmlInputText@1d42318
          +id: j_idt86
           type: org.richfaces.component.UIColumn@4c30e2
            +id: j_idt87
             type: javax.faces.component.UINamingContainer@1d6b89
              +id: j_id3
               type: javax.faces.component.UIPanel@1db3d85
                +id: input
                 type: javax.faces.component.html.HtmlInputText@17f1876
        +id: j_idt7
         type: 
        tt
        +id: j_idt88
         type: javax.faces.component.UINamingContainer@d09913
          +id: j_id3
           type: javax.faces.component.UIPanel@a42543
            +id: input  <===============
             type: javax.faces.component.html.HtmlInputText@f1be33
            +id: input  <===============
             type: javax.faces.component.html.HtmlInputText@830cc6
  +id: j_idt63
  type: 
</html>

请帮我

提前致谢

4

2 回答 2

0

它看起来像 RichFaces/JSF 中的一个错误。例如参考这个: https ://issues.jboss.org/browse/RF-13103

到目前为止,我在很多不同的组件(RichFaces 迭代组件和 JBoss Seam s:decorate)中遇到了同样的问题。很有趣,您遇到了 JSF 组件的问题,如果您能够在不使用 RichFaces 组件的情况下重现该问题,请针对 JSF 记录问题,或者给我一个可重现的示例,我会这样做。

尝试将 JSF 升级到最新版本,它可能会有所帮助。

现在,RF-13103 中描述的解决方法应该有所帮助(以性能为代价),而不是 UITree,使用 org.richfaces.component.UIOutputPanel (或任何其他包装有问题的区域)。

于 2013-10-10T14:35:47.957 回答
-1

你的复合组件有一个固定的 id,你不希望这样。

于 2013-10-10T13:26:21.253 回答