Dialog - Dynamic Focus By default, the first input field receives focus automatically. It can be changed by using focus attribute.
Dynamic Focus
<h:form>
            
    <p:commandButton value="Dynamic Focus" onclick="PF('dlg').show();" type="button" icon="ui-icon-extlink" />

    <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>
                
PrimeTek, Copyright © 2017
All rights reserved.
Running PrimeFaces-6.2-SNAPSHOT on Mojarra-2.3.2.