繁体   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