簡體   English   中英

參數值在Primefaces中串聯到動態列中嗎?

[英]Parameter values concatenated into dynamic columns in Primefaces?

我生成的是帶有Primefaces 4的JSF中數據表中的動態列。事實證明,這是通過兩個列表生成它的唯一方法,其中兩個列表具有數據網格和bean的其他屬性。 到目前為止,僅發生了這種情況。

<p:dataTable id="listCust" var="cust" value="#{mantClienteMB.customers}" rows="5"
     rowIndexVar="rowIndex" paginatorPosition="top" resizableColumns="true" emptyMessage="">

    <p:column headerText="N°" width="auto">
        <h:outputText value="#{rowIndex+1}" />
    </p:column>
    <c:forEach items="#{mantClienteMB.columnCustomer}" var="colum">
        <p:column headerText="#{colum.descripcion}" width="auto">
            <ui:fragment rendered="#{colum.entidadBean == 'code'}">
                <h:outputText value="#{cust.code}" />
            </ui:fragment>
            <ui:fragment rendered="#{colum.entidadBean == 'name'}">
                <h:outputText value="#{cust.name}" />
            </ui:fragment>
            <ui:fragment rendered="#{colum.entidadBean == 'comercialName'}">
                <h:outputText value="#{cust.comercialName}" />
            </ui:fragment>
            <ui:fragment rendered="#{colum.entidadBean == 'isActive'}">
                <h:outputText value="#{cust.isActive}" />
            </ui:fragment>
        </p:column>
    </c:forEach>            
</p:dataTable>

在代碼Java中:

private List<BaCustomer> customers;
private List<ValidColumnKey> columnCustomer; 

this.setCustomers(new ArrayList<BaCustomer>());
this.getCustomers().add(new BaCustomer("P0001", "PASSARELA S.A.C.", "PASSARELA", true));
this.getCustomers().add(new BaCustomer("P0002", "DARNOX S.A.C.", "DONOFRIO", true));

this.setColumnCustomer(new ArrayList<ValidColumnKey>());        
this.getColumnCustomer().add(new ValidColumnKey(1, "Codigo", "code"));  
this.getColumnCustomer().add(new ValidColumnKey(2, "Nombre", "name"));  
this.getColumnCustomer().add(new ValidColumnKey(3, "Nombre Comercial", "comercialName"));  
this.getColumnCustomer().add(new ValidColumnKey(4, "Estado", "isActive")); 

但是我想到,如果我可以將主列表中的別名值與我從第二個列表中獲得的屬性bean的名稱連接起來,則應該工作,但是沖突的問題是僅打印字符串,而不打印結果鏈。

<p:dataTable id="listCust" var="cust" value="#{mantClienteMB.customers}" rows="5"
             rowIndexVar="rowIndex" paginatorPosition="top" resizableColumns="true" emptyMessage="">

    <p:column headerText="N°" width="auto">
        <h:outputText value="#{rowIndex+1}" />
    </p:column>
    <c:forEach items="#{mantClienteMB.columnCustomer}" var="colum">
        <p:column headerText="#{colum.descripcion}" width="auto">
            <ui:param name="myVar" value="cust.#{colum.entidadBean}" />             
            <h:outputText value="#{myVar}" />                   
        </p:column>
    </c:forEach>            
</p:dataTable>

任何人都知道如何打印字符串值,而不僅僅是打印字符串作為說明。 圖片: http : //s2.subirimagenes.com/otros/previo/thump_8745153listcustomers.jpg

只需使用方括號書寫

#{cust[colum.entidadBean]}

希望能幫助到你...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM