In order to make the dialog nicely centered on the visible part of the page I have used a small java script function that positions the dialog for me after it is rendered by primefaces:
function positionDialog(dialogId,anchorId) {
var anchor = $(anchorId);
PF(dialogId).getJQ().position({
"my": "center",
"at": "center",
"of": $(anchor)
})
}
In your xhtml page all you have to do is to define the dialog and the anchor to which the dialog has to be moved to. The anchor should be put on the place of the page where the dialog should appear:
<div id="myAnchorId"></div>
<p:dialog id="myId"
header="My dialog"widgetVar="myId"
onShow="positionDialog(myId','#'+'myAnchorId')"
modal="true">
This is the content of my dialog
</p:dialog>
This way the dialog is always nicely centered no matter where your vertical scollbar is positioned at the moment.