By default, the first input field receives focus automatically. It can be changed by using focus attribute.
Documentation<h:form>
<p:commandButton value="Dynamic Focus" onclick="PF('dlg').show();" type="button" icon="pi pi-home" />
<p:dialog header="Dynamic Focus" widgetVar="dlg" focus="age">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="name" value="Name:" />
<p:inputText id="name" label="name" />
<h:outputLabel for="surname" value="Surname:" />
<p:inputText id="surname" label="surname" />
<h:outputLabel for="age" value="Age:" />
<p:inputText id="age" label="age" />
</h:panelGrid>
</p:dialog>
</h:form>