2

RF4 の方法を使用して rich:columns をビルドすると、奇妙な例外が発生しました。問題を再現する例を次に示します。

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: 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 に答える