2

I'm following the below example.

https://www.primefaces.org/showcase/ui/data/datatable/basic.xhtml

I would like to add prefix to the data table. How to add it?

Current Output

Id          Year    Brand   Color
1c859c99    1985    Honda   Maroon
37143be3    1993    Ford    Red
4cd0ff68    1985    Volvo   Black
8f12cce2    1963    Audi    White

Expected Output

Id          Year      Brand     Color
1c859c99    1985    Car Honda   Maroon
37143be3    1993    Car Ford    Red
4cd0ff68    1985    Car Volvo   Black
8f12cce2    1963    Car Audi    White

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

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

 </p:dataTable>

 <p:column headerText="Brand">
    <h:outputText Car?? value="#{car.brand}" />
 </p:column>
alicewo
  • 23
  • 2

1 Answers1

4

Take your pick.

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

They are all equally fine.

See also:

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555