Blame view

showcase/src/main/webapp/pages/focus/focus_5.xhtml 2.29 KB
bernard authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
<?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>On initial request focus should be placed on username. This is because direct parent of
            focus component is not UIInput.
            In such situation focus is put on first UIInput in parent form.
            Please not that focus component is not direct child of form.
            This sample is to ensure you that UIInput is not searched
            within direct parent of focus component, but within nesting form.
        </p>
        <ul>
            <li>username gets default priority 0</li>
            <li>email gets priority 1</li>
        </ul>
        <p>On form submit, when username is valid and email is invalid, focus
            should be placed on email.
        </p>

        <p>On form submit, when all fields are valid, focus
            should be placed on username.
        </p>
        <h:form>
            <h:panelGrid columns="3">
                <h:outputLabel value="Username" for="username"/>
                <h:inputText value="#{username}" id="username" required="true"/>
                <h:message for="username"/>
            </h:panelGrid>
            <h:panelGrid columns="3">
                <h:outputLabel value="Email" for="email"/>
                <h:inputText value="#{email}" id="email" required="true"/>
                <h:message for="email"/>
                <sand:focus/>
            </h:panelGrid>
            <h:commandButton value="Submit"/>
        </h:form>

        <rich:insert src="/focus_5.xhtml" highlight="html"/>

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