Ao entrar na página jsf 1.0 colocar o cursor no campo .....não está fazendo porque?

Olá,

pessoal ao entrar na página queria que o cursor fosse para o campo
fiz um javascript mais não está funcionando dei alert na function entra mais não executa …

o que pode ser???

abs

<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:rich="http://richfaces.org/rich" 
      xmlns:t="http://myfaces.apache.org/tomahawk" 
      xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" 
>
<ui:composition template="/public/templates/default.xhtml">
<ui:define name="body">

<head>

 <script>
      function iniciar(){
           // alert("aki");
			frm=document.forms[0];
			frm.nomeAluno.focus();
  	}
  		
  </script>

</head>

<body onload="iniciar();" >
<h:form>
<h:messages />
<demoiselle:useJs all="true">
</demoiselle:useJs>

<rich:panel  styleClass="richPanelStyleClass" bodyClass="richPanelBodyClass" headerClass="richPanelHeaderClass">

<h:outputLabel value="INFORMAÃ?Ã?ES PESSOAIS" />
<table summary="Formulário para Resposta do Aluno">

<br/>
<br/>

 &lt;tr&gt;
   &lt;td&gt;
      &lt;h:outputLabel  for="nomeAluno" styleClass="outputLabel" value="Nome do Aluno"/&gt;   
    &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
    &lt;td&gt;
     &lt;h:inputText required="true"  requiredMessage="Nome do Aluno Obrigatorio." maxlength="100" size="100"  id="nomeAluno" tabindex="1" styleClass="inputText" value="#{respostaAlunoMB.nomeAluno}" /&gt;
    &lt;/td&gt;  
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;/rich:panel&gt;
&lt;div style="padding: 10px; text-align: right;"&gt;
&lt;t:commandButton  title="Avançar"  value="Avançar" action="#{respostaAlunoMB.incluir_nome}"/&gt;
&lt;/div&gt;
&lt;/h:form&gt;
&lt;/body&gt;
&lt;/ui:define&gt;

&lt;/ui:composition&gt;


&lt;/html&gt;

template.xhtml

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" lang="pt-br"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
	&gt;
&lt;head&gt;
&lt;title&gt;&lt;ui:insert name="title"&gt;avalia&lt;/ui:insert&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;f:view&gt;
	&lt;demoiselle:useJs all="true" /&gt;
	&lt;demoiselle:useSkin /&gt;
	&lt;table width="100%" border="0" cellpadding="0" cellspacing="0"
		summary="Logo Demoiselle"&gt;
		&lt;!-- 
		style="background-image: url('./../../public/resources/images/logo-b.png')"&gt; --&gt;
		&lt;tr&gt;
			&lt;td align="left"&gt;&lt;h:graphicImage
				value="/public/resources/images/OK.png" alt="" height="100" /&gt;&lt;/td&gt;
		    &lt;td&gt; &lt;/td&gt;		
				&lt;!-- 
			&lt;td align="right"&gt;&lt;h:graphicImage
				value="/public/resources/images/IMAG_ZAIRE.png" height="100" alt="" /&gt;&lt;/td&gt;
				 --&gt;
		&lt;/tr&gt;
	&lt;/table&gt;
	&lt;table width="100%" border="0" cellpadding="0" cellspacing="0"
		summary="Seja bem vindo"&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;ui:insert name="navegation"&gt;
				&lt;rich:panel styleClass="richPanelStyleClass"
					bodyClass="richPanelBodyClass" headerClass="richPanelHeaderClass"&gt;
					&lt;h:outputText value="Seja bem vindo" /&gt;
					&lt;h:outputText value="" /&gt;
				&lt;/rich:panel&gt;
			&lt;/ui:insert&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;ui:insert name="menu"&gt;
				&lt;rich:toolBar height="34" itemSeparator="line"
					styleClass="richPanelBodyClass"&gt;
					&lt;h:form&gt;
						&lt;rich:toolBarGroup rendered="#{usuarioMB.isAdministrador}"&gt;
							&lt;h:commandLink value="Pergunta Aluno" title="Cadastro Pergunta Aluno"
								action="#{perguntaAlunoMB.listar}" /&gt;
						&lt;/rich:toolBarGroup &gt;
						
						&lt;rich:toolBarGroup rendered="#{usuarioMB.isAdministrador}"&gt;
							&lt;h:commandLink value="Pergunta Professor" title="Cadastro Pergunta Professor"
								action="#{perguntaProfessorMB.listar}" /&gt;
						&lt;/rich:toolBarGroup&gt;

						&lt;rich:toolBarGroup rendered="#{usuarioMB.isAdministrador}"&gt;
							&lt;h:commandLink value="Instituto" title="Instituto"
								action="#{institutoMB.listar}" /&gt;
						&lt;/rich:toolBarGroup&gt;

                        
                        &lt;rich:toolBarGroup rendered="#{usuarioMB.isAluno}"&gt;								
						&lt;h:commandLink value="Resposta Aluno" title="Resposta Aluno"
								action="#{respostaAlunoMB.digitar_nome}" /&gt;	
						&lt;/rich:toolBarGroup&gt;

                        &lt;rich:toolBarGroup rendered="#{usuarioMB.isProfessor}"&gt;								
						&lt;h:commandLink value="Resposta Professor" title="Resposta Professor"
								action="#{respostaProfessorMB.digitar_nome}" /&gt;	
						&lt;/rich:toolBarGroup&gt;
						
						&lt;rich:toolBarGroup rendered="#{usuarioMB.isAdministrador}"&gt;
								&lt;h:commandLink value="Tema" action="#{escolaMB.listarSkin}" title="Configuracao de Temas " id="F11" /&gt;
						&lt;/rich:toolBarGroup&gt;

             			&lt;rich:toolBarGroup &gt;
								&lt;a4j:commandLink value="Sair"  action="#{escolaMB.sair}" oncomplete="javascript:logout()"  title="Sair da Aplicação " id="F12" /&gt;
						&lt;/rich:toolBarGroup&gt;
							 
												
					&lt;/h:form&gt;
				&lt;/rich:toolBar&gt;
			&lt;/ui:insert&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;ui:insert name="message"&gt;
				&lt;h:messages globalOnly="true" errorClass="errorFatalMessage"
					fatalClass="errorFatalMessage" infoClass="infoMessage"
					warnClass="warnMessage" showSummary="true" showDetail="false" /&gt;
			&lt;/ui:insert&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;ui:insert name="body"&gt;
			&lt;/ui:insert&gt;&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;
&lt;/f:view&gt;
&lt;/body&gt;
&lt;/html&gt;

Kra tentar usar algo tipo ha não precisa informar nada no onload do form

<script>
			window.onload = function(){
			 document.getElementById('id completo do seu campo comforme é exibido na html apos gerada na página').focus();	
                       };
                               
		</script>

continua a mesma coisa entra na página e não vai para o campo o cursor.

abs

o que fiz

&lt;ui:composition template="/public/templates/default.xhtml"&gt;
&lt;/script&gt;
  
   &lt;script&gt;  
    window.onload = function(){  
    document.getElementById('nomeAluno').focus();    
     };  
                                  
&lt;/script&gt;



&lt;body&gt;
&lt;h:form&gt;
&lt;h:messages /&gt;
&lt;demoiselle:useJs all="true"&gt;
&lt;/demoiselle:useJs&gt;

&lt;rich:panel  styleClass="richPanelStyleClass" bodyClass="richPanelBodyClass" headerClass="richPanelHeaderClass"&gt;

&lt;h:outputLabel value="INFORMAÃ?Ã?ES PESSOAIS.." /&gt;
&lt;table summary="Formulário para Resposta do Aluno"&gt;

<br/>
<br/>

 &lt;tr&gt;
   &lt;td&gt;
      &lt;h:outputLabel  for="nomeAluno" styleClass="outputLabel" value="Nome do Aluno"/&gt;   
    &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
    &lt;td&gt;
     &lt;h:inputText required="true"  requiredMessage="Nome do Aluno Obrigatorio." maxlength="100" size="100"  id="nomeAluno" tabindex="1" styleClass="inputText" value="#{respostaAlunoMB.nomeAluno}" /&gt;
    &lt;/td&gt;  
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;/rich:panel&gt;
&lt;div style="padding: 10px; text-align: right;"&gt;
&lt;t:commandButton  title="Avançar"  value="Avançar" action="#{respostaAlunoMB.incluir_nome}"/&gt;
&lt;/div&gt;
&lt;/h:form&gt;
&lt;/body&gt;
&lt;/ui:define&gt;

&lt;/ui:composition&gt;


&lt;/html&gt;
  

template


&lt;head&gt;
&lt;title&gt;&lt;ui:insert name="title"&gt;avalia&lt;/ui:insert&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;f:view&gt;
	&lt;demoiselle:useJs all="true" /&gt;
	&lt;demoiselle:useSkin /&gt;
	&lt;table width="100%" border="0" cellpadding="0" cellspacing="0"
		summary="Logo Demoiselle"&gt;
		&lt;!-- 
		style="background-image: url('./../../public/resources/images/logo-b.png')"&gt; --&gt;
		&lt;tr&gt;
			&lt;td align="left"&gt;&lt;h:graphicImage
				value="/public/resources/images/cccccc.png" alt="" height="100" /&gt;&lt;/td&gt;
		    &lt;td&gt; &lt;/td&gt;		
				&lt;!-- 
			&lt;td align="right"&gt;&lt;h:graphicImage
				value="/public/resources/images/kkk.png" height="100" alt="" /&gt;&lt;/td&gt;
				 --&gt;
		&lt;/tr&gt;
	&lt;/table&gt;
	&lt;table width="100%" border="0" cellpadding="0" cellspacing="0"
		summary="Seja bem vindo"&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;ui:insert name="navegation"&gt;
				&lt;rich:panel styleClass="richPanelStyleClass"
					bodyClass="richPanelBodyClass" headerClass="richPanelHeaderClass"&gt;
					&lt;h:outputText value="Seja bem vindo" /&gt;
					&lt;h:outputText value="" /&gt;
				&lt;/rich:panel&gt;
			&lt;/ui:insert&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;ui:insert name="menu"&gt;
				&lt;rich:toolBar height="34" itemSeparator="line"
					styleClass="richPanelBodyClass"&gt;
					&lt;h:form&gt;
						&lt;rich:toolBarGroup rendered="#{usuarioMB.isAdministrador}"&gt;
							&lt;h:commandLink value="Pergunta Aluno" title="Cadastro Pergunta Aluno"
								action="#{perguntaAlunoMB.listar}" /&gt;
						&lt;/rich:toolBarGroup &gt;
						
						&lt;rich:toolBarGroup rendered="#{usuarioMB.isAdministrador}"&gt;
							&lt;h:commandLink value="Pergunta Professor" title="Cadastro Pergunta Professor"
								action="#{perguntaProfessorMB.listar}" /&gt;
						&lt;/rich:toolBarGroup&gt;

						&lt;rich:toolBarGroup rendered="#{usuarioMB.isAdministrador}"&gt;
							&lt;h:commandLink value="Instituto" title="Instituto"
								action="#{institutoMB.listar}" /&gt;
						&lt;/rich:toolBarGroup&gt;

                        &lt;rich:toolBarGroup rendered="#{usuarioMB.isProfessor}"&gt;								
						&lt;h:commandLink value="Resposta Professor" title="Resposta Professor"
								action="#{respostaProfessorMB.digitar_nome}" /&gt;	
						&lt;/rich:toolBarGroup&gt;
						
						
                       &lt;rich:toolBarGroup rendered="#{usuarioMB.isAluno}"&gt;								
						&lt;h:commandLink value="Resposta Aluno" title="Resposta Aluno"
								action="#{respostaAlunoMB.digitar_nome}" /&gt;	
						&lt;/rich:toolBarGroup&gt;
						
						
						&lt;rich:toolBarGroup rendered="#{usuarioMB.isAdministrador}"&gt;
								&lt;h:commandLink value="Tema" action="#{escolaMB.listarSkin}" title="Configuracao de Temas " id="F11" /&gt;
						&lt;/rich:toolBarGroup&gt;
						
 			            &lt;rich:toolBarGroup rendered="#{usuarioMB.isAdministrador}"&gt;
							&lt;h:commandLink value="Limpeza Resposta Aluno" title="Limpeza de Resposta de Aluno"
								action="#{respostaAlunoMB.limpezaAluno}" /&gt;
						&lt;/rich:toolBarGroup&gt;
 
             			&lt;rich:toolBarGroup &gt;
								&lt;a4j:commandLink value="Sair"  action="#{escolaMB.sair}" oncomplete="javascript:logout()"  title="Sair da Aplicação " id="F12" /&gt;
						&lt;/rich:toolBarGroup&gt;
							 
												
					&lt;/h:form&gt;
				&lt;/rich:toolBar&gt;
			&lt;/ui:insert&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;ui:insert name="message"&gt;
				&lt;h:messages globalOnly="true" errorClass="errorFatalMessage"
					fatalClass="errorFatalMessage" infoClass="infoMessage"
					warnClass="warnMessage" showSummary="true" showDetail="false" /&gt;
			&lt;/ui:insert&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;ui:insert name="body"&gt;
			&lt;/ui:insert&gt;&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;
&lt;/f:view&gt;
&lt;/body&gt;
&lt;/html&gt;