<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="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:focus="http://richfaces.org/sandbox/focus"xmlns:rich="http://richfaces.org/rich"xmlns:a4j="http://richfaces.org/a4j"><head><title>Focus sample</title></head><body><ui:includesrc="menu.xhtml"/><p> Focus is placed on control withing modal panel. Modal panel is rendered before it is shown, thus javascript that sets focus should not be invoked at that moment. To cope with that focus component has "timing" attribute which, when valued to "onJScall" allows setting focus later whenever user wishes. When "timing" is set to "onJScall" then "name" attribute must be also specified. It is name of JavaScript function that will be generated and can be called by user to set focus in any moment. In this example we put onshow="focusTheForm();" in modal panel which causes focus to be placed after the modal is visible. Notice that "name" attribute of focuse component is equal to "focusTheForm".</p><h:form><h:commandButtonvalue="Show modal"><rich:componentControlfor="panel"event="onclick"operation="show"disableDefault="true"/></h:commandButton></h:form><rich:modalPanelid="panel"autosized="true"onshow="focusTheForm();"><h:formid="theForm"><focus:focusname="focusTheForm"timing="onJScall"/><h:panelGridcolumns="3"><h:outputLabelvalue="Username"for="username"/><h:inputTextvalue="#{username}"id="username"required="true"/><h:messagefor="username"/><h:outputLabelvalue="Email"for="email"/><h:inputTextvalue="#{email}"id="email"required="true"/><h:messagefor="email"/></h:panelGrid><a4j:commandButtonvalue="Submit"reRender="theForm"oncomplete="Richfaces.FocusManager.focus();"/><h:commandButtonvalue="Close"><rich:componentControlfor="panel"event="onclick"operation="hide"disableDefault="true"/></h:commandButton></h:form></rich:modalPanel><rich:insertsrc="/focus_6.xhtml"highlight="html"/></body></html>