Footer is not displayed (actually, it is incorrectly displayed on top of the page), when fullPage
is set to false in PrimeFaces template.
<p:layout fullPage="false">
<p:layoutUnit position="north" size="135">
<!--Put north content here, if any-->
</p:layoutUnit>
<p:layoutUnit position="west" size="225" header="Menu Item" collapsible="true">
<!--Put west content here, if any-->
</p:layoutUnit>
<p:layoutUnit position="center" size="2500" maxSize="2500">
<!--Put center content here, if any-->
</p:layoutUnit>
<p:layoutUnit position="east" size="175">
<!--Put east content here, if any-->
</p:layoutUnit>
<p:layoutUnit position="south" size="90">
<!--Put south/footer content here, if any-->
</p:layoutUnit>
</p:layout>
How to display footer, when fullpage
is set to false?
EDIT :
if <p:layout>
is given a height like as follows,
<p:layout fullPage="false" style="height: 2000px;">
then the footer is displayed at the bottom of the page based on the value of the height
CSS attribute but it is still not a sticky footer - it does not adjust according to the page contents.
So, Is there a way to make it sticky?
Update :
The behaviour remains stationary on PrimeFaces 5.3 final (community release), when fullPage
is set to false
as said previously throughout the question.
To easily visualize what you ultimately need (and to confirm your needs for myself), here's in SSCCE flavor a pure HTML/CSS solution of what you're (apparently) asking for. The sticky footer solution is largely based on Ryan Fait's approach (a
min-height:100%
and a negative margin on the container element which covers everything but footer), it only doesn't support IE6/7 anymore (due to:after
pseudoselector), hereby simplifying the HTML markup (no non-semantic clutter like<div id="pushfooter">
needed). Note: background colors are purely for visualization.Note: due to the way how floats work, the
<div id="side">
(the "east unit") has in the HTML markup to be placed before all non-floating elements at the same "row", such as the<div id="content">
(the "center unit"), otherwise it will be aligned relative to the bottom of the last non-floating element.Now, in order to achieve exactly the same with the
<p:layout>
thing, which basically renders almost the same HTML structure, only with the footer still inside the container and the east unit after the center unit, you need to make sure that no one of the layout units are collapsible/closable/resizable (those attributes all already default tofalse
and can thus be omitted for brevity) and that you apply the PrimeFaces-builtin clearfix style classui-helper-clearfix
on the container unit to clear the floats (otherwise the menu, content and side would overlap the footer when the screen is shrunk vertically):Then you can apply the following CSS in your PrimeFaces-override stylesheet to remove/override all "irrelevant" PrimeFaces-generated CSS properties on those layout units by setting the absolute positioning with fixed offsets/dimensions back to initial/default values (note: the exact purpose of
!important
is being able to override hardcoded/inlinestyle
properties from a true stylesheet on, there's in this particular case simply no other option as long as you don't want to rewrite PrimeFaces components and renderers). Key point is that you should end up with exactly the same HTML/CSS (defaults) as the SSCCE:And finally add the following script in order to move the side (east unit) before the content (center unit), so that the floats go as intented, and to move the footer to end of body, so that it's outside the container element:
Make sure that this script is re-executed when you do an ajax update with
@all
on the same view for some reason (which is at its own a bad idea though).With this "solution" (I'd rather call it a hack and just throw it all away and go for a sane and clean HTML/CSS solution, if necessary with
<p:panel>
s instead of<div>
s), it's still somewhat brittle; the auto-includedlayout.js
script auto-adjusts the layout units on every window resize. But so far they don't seem to break anything in all modern browsers I tried (IE>8).This may or may not be a bug in PrimeFaces - you're best off asking there. The layout is actually on your page if you check the source, however its positioning is above the header, likely because it has no idea where it's to be. In a full page it knows its location generated by the page, but otherwise it could be anywhere you want it to be. Try using CSS to move it etc, refer to. and use
styleClass
etc to attach classes, my hack was just to use!important
which you shouldn't really do.etc..
Although I am more inclined to think this is a bug as none of the CSS is applied properly to it.
I've created an issue report on PF and hopefully someone can give some more information on the problem.
Apparently
<p:layout>
requires an appropriate height, whenfullPage
is set tofalse
. The height is required to display the footer at appropriate position (it should position at the bottom of the browser window) like,Learnt from PrimeFaces Extensions
<pe:layout>
which fails to work with the following error in JavaScript alert box on page load,if
fullPage
of<pe:layout>
is set tofalse
and height is not defined. For it to work appropriately, it needs an appropriate height like as follows.It is difficult to tell whether it is deliberate or intentional.
It would be delightful, if someone could expose how to adjust the footer according to the page contents, a sticky footer.
To ensure that the layout DIV has a relative height :
1_ Every components between the BODY and the layout must have a relative height, witch should be 100%.
2_ Always use DIV instead of SPAN between the BODY and your layout (no inline elements).
exemple :
In case, it dosent work add this code to your page, (i fixed a long time ago but its probably has a relationship with your problem) :
i also suggest you, to use the layout of PF Extention library, its more stable, a working template can be found here erp.agitech.net admin/pass