0

I am using a primefaces datatable. Each row in the datatable will have 24 columns representing 24 hour values. As of now I am using a static xhtml with 24 columns coded individually, I would like it to make it dynamic so that the code can be maintained easily, The input textbox under the columns are fetched from an array. When I try to use the over the array I dont see the columns getting created horizontally. PFA the below code.

Inside the parent.xhtml we have the dataTable,

    <p:dataTable id="tbl" var="row" value="#{prvdr.values}" 
binding="#{prvdr.dataTable}" widgetVar="table" filteredValue="#{prvdr.filteredList}" 
scrollable="true" scrollWidth="auto" lazy="false" rowKey="#{row.id}" paginator="true" 
filterEvent="enter" paginatorTemplate="#{appmsg['label.recordsperpage']}: {RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15,20,50" editable="true" editMode="cell">
<ui:include src="hourly.xhtml" />

</p:dataTable>

Inside the included hourly.xhtml

    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    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:p="http://primefaces.org/ui">

    <ui:repeat items="#{row.hourArray}" var="item" varStatus="myVarStatus">
        <p:column styleClass="col-right col-90">
            <f:facet name="header">
                <h:outputText value="myVarStatus.index" escape="false" />
            </f:facet>
            <p:cellEditor>
                <f:facet name="output">
                    <h:outputText value="#{item}" escape="false">
                        <f:convertNumber maxFractionDigits="3" minFractionDigits="3"
                            maxIntegerDigits="5" />
                    </h:outputText>
                </f:facet>
                <f:facet name="input">
                    <p:inputText value="#{item}" maxlength="10" size="10">
                        <f:convertNumber maxFractionDigits="3" minFractionDigits="3"
                            maxIntegerDigits="5" />
                    </p:inputText>
                </f:facet>
            </p:cellEditor>
        </p:column>
    </ui:repeat>
</ui:composition>

the Row object is backed by a java class where hourArray is represented as below.

private BigDecimal[] hourArray;

I tried both ui:repeat and c:forEach but couldnt create the desired view. Any help and suggestions are welcome.

Sabarish
  • 862
  • 1
  • 14
  • 23
  • The `` will definitely not work as it does not run during view build time but only during view render time. The `` should however work. What exactly is the problem you're having with it? The statement "couldnt create the desired view" is too vague. Please elaborate the concrete problem in developer's perspective. – BalusC May 28 '13 at 16:28
  • @BalusC Instead of as in above code I replaced it with .... .... but still the columns are not created horizontally. – Sabarish May 28 '13 at 18:09
  • The `` won't show **any** columns at all because that's an invalid approach. But with `` you're thus actually seeing the desired columns? Yet only the layout is not entirely right, is that what you're saying? In any way, as I'm unable to help you out based on the poor problem description provided so far, here's a link which should provide new insight: http://stackoverflow.com/questions/13176842/dynamically-generate-hcolumn-based-on-list-of-hashmaps/13177299#13177299 – BalusC May 28 '13 at 18:25
  • @BalusC Excuse my use of words above. When I say 'couldnt create the desired view' I am saying still I dont see the columns created. I tried like this . But still no columns were generated. – Sabarish May 29 '13 at 13:40

0 Answers0