Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PrimeFaces: JSON and DataTable

Usually PrimeFaces uses java object get methods to set the values for a data table component. Is there a way to instead use a JSON request to fill the table with data?

Sample Data Table:

<p:dataTable var="car" value="#{dtBasicView.cars}">
    <p:column headerText="Id">
        <h:outputText value="#{car.id}" />
    </p:column>

    <p:column headerText="Year">
        <h:outputText value="#{car.year}" />
    </p:column>

    <p:column headerText="Brand">
        <h:outputText value="#{car.brand}" />
    </p:column>

    <p:column headerText="Color">
        <h:outputText value="#{car.color}" />
    </p:column>
</p:dataTable>

Instead is there a way to do:

<p:dataTable var="car" data-url="data1.json">

or some equivalent?

What about using tag to request JSON data and fill the table?

I am looking for a way to request JSON from HTML to fill a prime faces component in the view not the managed bean controller.

like image 286
wwjdm Avatar asked May 19 '26 10:05

wwjdm


1 Answers

Replace the first word of your question with 'always' and you have your answer: you can't.

Use the PrimeUI datatable instead: http://www.primefaces.org/primeui/#datatable

like image 132
Kukeltje Avatar answered May 21 '26 01:05

Kukeltje