0

When I use stickyHeader on a datatable inside of a layoutUnit the headers are displayed twice, with the second header slightly offset vertically and horizontally. When I use the same table not in a layoutUnit it displays correctly. When I scroll down and the header sticks to the top it displays correctly. I've tried examining the generated html and css but am unable to fix it.

Using Primefaces 6.1.

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui">

<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<h:outputStylesheet library="css" name="primefaces.css"/>
</h:head>


<p:layout id="lo1">
<p:layoutUnit id="lu1" position="center">
    <p:dataTable value="#{simpleController.simpleObjects}" var="simpleObject" stickyHeader="true">
        <p:column headerText="attr1">
            <p:outputLabel value="#{simpleObject.attr1}"/>
        </p:column>
        <p:column headerText="attr2">
            <p:outputLabel value="#{simpleObject.attr2}"/>
        </p:column>
        <p:column headerText="attr3">
            <p:outputLabel value="#{simpleObject.attr3}"/>
        </p:column>
    </p:dataTable>
</p:layoutUnit>

</p:layout>

</html>

And this is the same table but not in a layoutUnit

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui">

<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<h:outputStylesheet library="css" name="primefaces.css"/>
</h:head>

<p:dataTable value="#{simpleController.simpleObjects}" var="simpleObject" stickyHeader="true">
<p:column headerText="attr1">
    <p:outputLabel value="#{simpleObject.attr1}"/>
</p:column>
<p:column headerText="attr2">
    <p:outputLabel value="#{simpleObject.attr2}"/>
</p:column>
<p:column headerText="attr3">
    <p:outputLabel value="#{simpleObject.attr3}"/>
</p:column>
</p:dataTable>
</html>
user6627139
  • 406
  • 6
  • 16
  • if this is your [mcve], you indirectly state that it works if you remove the `primefaces.css` which is btw an uncommon name since it is most likely your css and not a primefaces one. And (off-topic, but good) also read https://stackoverflow.com/questions/11988415/what-is-the-jsf-resource-library-for-and-how-should-it-be-used. And please did you search the PrimeFaces issuelist? – Kukeltje Dec 03 '19 at 19:08
  • 3
    Sticky does not support Layout. Layout is deprecated and will be removed in PF 9.0 – Melloware Dec 03 '19 at 21:10
  • I saw (after posting) that layout is deprecated. So I am going the route of updating code to not use layout. Thanks for responses. – user6627139 Dec 04 '19 at 01:15
  • 1
    You could switch to https://www.primefaces.org/showcase-ext/views/layout.jsf @Melloware there are no plans on removing that one soon, right? – Jasper de Vries Dec 04 '19 at 08:50
  • Correct you can use the PrimeFaces Extensions Layout if you need to. – Melloware Dec 04 '19 at 12:03

0 Answers0