简体   繁体   English

参数值在Primefaces中串联到动态列中吗?

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

I'm generating is so dynamic columns in a datatable in JSF with Primefaces 4. It turns out that the only way to generate it through two lists where one has data grid and other attributes of the bean. 我生成的是带有Primefaces 4的JSF中数据表中的动态列。事实证明,这是通过两个列表生成它的唯一方法,其中两个列表具有数据网格和bean的其他属性。 So far it has happened only handle this. 到目前为止,仅发生了这种情况。

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

In code java: 在代码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")); 

But it occurred to me that if I could concatenate the value of the alias in the main list with the names of the attributes bean I get from the second list should work, but the problem of contenacion is that only prints the string, but not the result chain. 但是我想到,如果我可以将主列表中的别名值与我从第二个列表中获得的属性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>

Anyone have an idea how to print the string value and not just the string as description. 任何人都知道如何打印字符串值,而不仅仅是打印字符串作为说明。 Image: http://s2.subirimagenes.com/otros/previo/thump_8745153listcustomers.jpg 图片: http : //s2.subirimagenes.com/otros/previo/thump_8745153listcustomers.jpg

Just use bracket-writing 只需使用方括号书写

#{cust[colum.entidadBean]}

Hope it helps... 希望能帮助到你...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM