focus_1.xhtml 1.57 KB
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:sand="http://richfaces.org/sandbox"
      xmlns:a4j="http://richfaces.org/a4j" 
      xmlns:rich="http://richfaces.org/rich"
      template="./../../template.xhtml">

    <ui:define name="htmlHead">
        <title>Focus sample</title>
    </ui:define>

    <ui:define name="header">
        <ui:include src="menu.xhtml"/>
    </ui:define>

    <ui:define name="content">
        <p>Focus should be placed on email:
            <ul>
                <li>username gets default priority 0</li>
                <li>email gets priority -1</li>
            </ul>
        </p>

        <h:form>
            <h:panelGrid columns="3">
                <h:outputLabel value="Username" for="username"/>
                <h:inputText value="#{username}" id="username" required="true">
                    <sand:focus/>
                </h:inputText>
                <h:message for="username"/>

                <h:outputLabel value="Email" for="email"/>
                <h:inputText value="#{email}" id="email" required="true"/>
                <h:message for="email"/>
            </h:panelGrid>
            <h:commandButton value="Submit"/>
            <sand:focus for="email" priority="-1"/>
        </h:form>

    </ui:define>
</ui:composition>