0

The value defined by c:set refers to a var (name of the iterator variable used to refer each data), but the column values are not displayed.

How should it be defined to be displayed correctly?

<c:set var="column1_label" value="Id" scope="view" />
<c:set var="column1_value" value="#{data.id}" scope="view" />
<c:set var="column2_label" value="Code" scope="view" />
<c:set var="column2_value" value="#{data.code}" scope="view" />
<c:set var="column3_label" value="Name" scope="view" />
<c:set var="column3_value" value="#{data.name}" scope="view" />

<p:dataTable id="dataTableId" value="#{testView.products}" var="data">
    <c:forEach begin="1" end="3" var="idx">
        <p:column headerText="#{viewScope['column' += idx += '_label']}">
            <h:outputText value="#{viewScope['column' += idx += '_value']}" />
        </p:column>
    </c:forEach>
</p:dataTable>

we have some hundred different views which contain one or more datatables. therefore we build a template containing the datatable which we include on different sites. to keept it simple we want to define the columns of datatable which should hold also the values. not to have to define each column separate in that template we would prefer to have a loop for all that columns (see sample above), because of complex stuff which column can have (different format, different inputfields, converter, editmode, colors,.... which should be configured with c:set in all that views). Problem is that it seems to be impossible to get the value because ui:param is not suitable and c:set also doesn't work with name of iterator variable name.

4
  • This question is similar to: JSTL in JSF2 Facelets... makes sense?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Feb 12 at 12:50
  • 1
    Why would you do this and why not just modify the model to hold what you need instead? What is the goal? Commented Feb 14 at 11:52
  • Did you check primefaces.org/showcase/ui/data/datatable/columns.xhtml ? Commented Feb 17 at 14:47
  • yes, but that sample is not an option Commented Feb 18 at 7:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.