Pessoal estou com um problemão… Em todas as minhas páginas quando eu dou um enter em algum campo ele submete a minha página e consequentemente é gerado um erro.
Eu consigo bloquear isso ?
A solução que eu conheço é colocar no onsubmit uma função de validação, mas eu teria um retrabalho imenso…
Imagino que se vc usa-se a tecla TAB ao inves de enter seria melhor do que ficar apertando o ENTER. Mas tb tem outro lado que se vc deve estar preenchendo alguma coisa, um formulario ou coisa do tipo, certo ? E esse formulario terá validações, nem que elas sejam em JS, certo ? pois bem, se por acaso vc errasse e apertasse o enter, cairia na validação e seu problema diminuiria. Esse é so uma ideia.
falo
Abs
S
saga_fuel
O jeito mais rapido eu acho que seria através do javascript tb!!
quando todos os campos estivessem preenchidos voce poderia preencher o action do form,
agora não sou expert!!eheheh só tentei ajudar;…r
R
rodrigus
Isso acontece por que cada componente está em um form específico, talvez vc esteja usando o Dreamweaver que faz isso automaticamente. Coloque todos dentro de um form só, assim:
Mas vc não usará ENTER pra passar de um componente p outro, tem que usar TAB.
Z
zezinho
rodrigus:
Isso acontece por que cada componente está em um form específico, talvez vc esteja usando o Dreamweaver que faz isso automaticamente. Coloque todos dentro de um form só, assim:
Mas vc não usará ENTER pra passar de um componente p outro, tem que usar TAB.
Não estou usando o Dreamweaver, todos meus campos estão no meu formBean, o problema que eu não quero usar o enter ou o tab para mudar de campo, o que ouve foi um acidente, apertei o enter por acaso quando eu estava preenchendo um campo, pelo que eu estou vendo terei que fazer uma validação no onsubmit… será que só tem essa saída ?
R
rodrigus
é bem possível então.
Z
zezinho
O pior que nesta jsp não tenho o problema..Quando eu clico em qualquer campo não ocorre nada..somente com o click do botão
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@tagliburi="/tags/struts-html"prefix="html"%><%@tagliburi="/tags/struts-bean"prefix="bean"%><%@tagliburi="/tags/struts-logic"prefix="logic"%><html:base/><html:html><head><title>..</title><METAHTTP-EQUIV="Pragma"CONTENT="no-cache"><LINKrel="stylesheet"type="text/css"href="/componentes/estilosApp.css"><LINKrel="stylesheet"type="text/css"href="/veic/componentes/veic_style.css"><SCRIPTlanguage="JavaScript"src="/veic/componentes/veic_scripts.js"></SCRIPT><SCRIPTlanguage="JavaScript">functionAlterar(){if(document.getElementById('codigoParametro').value.length==0){alert("Selecione um banco.")}else{document.manterBancoForm.action='../../../manterBancoAction.do?parAcao=recuperar';document.manterBancoForm.submit();}}functionIncluir(){document.manterBancoForm.action="../../../manterBancoAction.do?parAcao=carregarInclusao";document.manterBancoForm.submit();}functionExcluir(){if(document.getElementById('codigoParametro').value.length==0){alert("Selecione um banco.")}elseif(confirm("Tem certeza que deseja excluir este banco ?")){document.manterBancoForm.action='../../../manterBancoAction.do?parAcao=excluir';document.manterBancoForm.submit();}}functionPesquisar(){divListaItens.style.display="";document.manterBancoForm.action='../../../manterBancoAction.do?parAcao=pesquisarPorParam';document.manterBancoForm.submit();}functionsetaValor(valor){document.getElementById('codigoParametro').value=valor;}</SCRIPT></head><BODYclass="fnd1"><html:formaction="/manterBancoAction"><inputtype="hidden"name="codigoParametro"><logic:messagesPresentname="message"><html:messagesid="message"message="true"><bean:writename="messages"/></html:messages></logic:messagesPresent><!-- ####### Tabela de Alinhamento ####### --><TABLEborder="0"cellpadding="0"cellspacing="0"width="748"><TR><TDcolspan="2"height="5"></TD></TR><TR><TDwidth="21"></TD><TD><!-- ####### Titulo ####### --><DIVid="divTitulo"style="width:100%"><p><FONTclass="ttl2">Manutenção</FONT><BR><FONTclass="ttl1">Manter Banco</FONT></p></DIV><!-- ####### Pesquisa ####### --><DIVid="divPesquisa"style="width:100%;padding-top:10px;"><TABLEborder="1"borderColor="#990000"borderColorDark="white"cellpadding="3"cellspacing="0"rules="rows"frame="below"class="tab1"width="100%"><TRalign="center"><TDcolspan='6'class='ttltab1'>Opções de Pesquisa</TD></TR><TR><TDwidth="80"class="lbl1"><b>Cód. Banco:</b></TD><TD><html:textproperty="codigo"size="15"onkeypress="onlyNum()"styleClass="txt1"/></TD><TDwidth="85"class="lbl1"><b>Nome Banco:</b></TD><TD><html:textproperty="nome"styleClass="txt1"/></TD><TDwidth="60"class='txt1'><b>Situação:</b></TD><TD><html:selectproperty="ativo"styleClass="frmCmb1"><html:optionvalue="T">Todos</html:option><html:optionvalue="A">Ativo</html:option><html:optionvalue="I">Inativo</html:option></html:select></TD></TR></TABLE></DIV><!-- ####### LISTA DE ITENS ####### --><!-- <IFRAME src="pesq_bancoGrade.jsp" height="180" width="100%" scrolling="auto" frameborder=0 name="frameDados" id="frameDados"></IFRAME> --><DIVid="divListaItens"style="width:100%;display: none"><TABLEborder="1"borderColor="#990000"borderColorDark="white"cellpadding="3"cellspacing="0"rules="rows"frame="below"class="tab1"width="100%"><TRalign="center"><TDcolspan="7"class="ttlTab1">Bancos</TD></TR><TRalign="center"><TDwidth="20"class="ttlTab2"> </TD><TDwidth="80"class="ttlTab2"><B>Cód. Banco</B></TD><TDwidth="300"class="ttlTab2"align="left"><B>Nome Banco</B></TD><TDwidth="100"class="ttlTab2"><B>Sigla</B></TD><TDwidth="100"class="ttlTab2"><B>Agrupado</B></TD><TDclass="ttlTab2"><B>Situação</B></TD><TDwidth="10"class="ttlTab2"> </TD></TR></TABLE><DIVid="divScroll"style="height:140px"><TABLEborder="1"borderColor="#990000"borderColorDark="white"cellpadding="3"cellspacing="0"rules="rows"frame="below"class="tab1"width="100%"><logic:presentname="listaBanco"><logic:iteratename="listaBanco"id="lista"><TRalign="center"><TDwidth="20"class="txtTab1"><inputtype="radio"name="itemSelecao"id="<bean:write property="codigo"name="lista"/>" value="radiobutton" class="frmTxt1" onclick="setaValor('<bean:writeproperty="codigo"name="lista"/>')"></TD><TDwidth="80"class="txtTab1"><bean:writeproperty="codigo"name="lista"/></TD><TDwidth="300"class="txtTab1"align="left"><bean:writeproperty="nome"name="lista"/></TD><TDwidth="100"class="txtTab1"><bean:writeproperty="sigla"name="lista"/></TD><TDwidth="100"class="txtTab1"><bean:writeproperty="agrupado"name="lista"/></TD><TDclass="txtTab1"><bean:writeproperty="ativo"name="lista"/></TD></TR></logic:iterate></logic:present></TABLE></DIV></DIV><!-- ####### BOTOES ####### --><DIVid="divBotoes"><DIVid="botaoIncluir"><INPUTtype="Button"id="btoIncluir"name="btoIncluir"value="incluir"class="bto1"onclick="Incluir()"></DIV><DIVid="botaoAlterar"style="display:none"><INPUTtype="Button"id='btoAlterar'name='btoAlterar'value="alterar"class="bto1"onclick="Alterar()"></DIV><DIVid="botaoExcluir"style="display:none"><INPUTtype="Button"id='btoExcluir'name='btoExcluir'value="excluir"class="bto1"onclick="Excluir()"></DIV><DIVid="botaoPesquisar"><INPUTtype=buttonclass=bto1Value='pesquisar'id='bt_pesquisar'name='bt_pesquisar'align='left'onClick='Pesquisar()'></DIV></DIV></TD></TR><logic:presentname="lista"><logic:notEmptyname="lista"><script>divListaItens.style.display="";document.getElementById("botaoExcluir").style.display="";document.getElementById("botaoAlterar").style.display="";</script></logic:notEmpty></logic:present><logic:notPresentname="lista"><logic:emptyname="lista"><script>divListaItens.style.display="none";document.getElementById("botaoExcluir").style.display="none";document.getElementById("botaoAlterar").style.display="none";</script></logic:empty></logic:notPresent></TABLE></html:form></body><logic:presentname="mensagem"><script>alert('<bean:write name="mensagem" />')</script></logic:present></html:html>
Já essa, que aparentemente estão iguais ocorre o erro.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@tagliburi="/tags/struts-html"prefix="html"%><%@tagliburi="/tags/struts-bean"prefix="bean"%><%@tagliburi="/tags/struts-logic"prefix="logic"%><html:base/><html:html><head><title>VEIC</title><METAHTTP-EQUIV="Pragma"CONTENT="no-cache"><LINKrel="stylesheet"type="text/css"href="/componentes/estilosApp.css"><LINKrel="stylesheet"type="text/css"href="/veic/componentes/veic_style.css"><SCRIPTlanguage="JavaScript"src="/veic/componentes/veic_scripts.js"></SCRIPT><SCRIPTlanguage="JavaScript">functionAlterar(){if(document.getElementById('codigoParametro').value.length==0){alert("Selecione uma Característica.")}else{document.manterCaracteristicaForm.action='../../../manterCaracteristicaAction.do?parAcao=recuperar';document.manterCaracteristicaForm.submit();}}functionIncluir(){document.manterCaracteristicaForm.action="../../../manterCaracteristicaAction.do?parAcao=carregarInclusao";document.manterCaracteristicaForm.submit();}functionExcluir(){if(document.getElementById('codigoParametro').value.length==0){alert("Selecione um banco.")}elseif(confirm("Tem certeza que deseja excluir este banco ?")){document.manterCaracteristicaForm.action='../../../manterCaracteristicaAction.do?parAcao=excluir';document.manterCaracteristicaForm.submit();}}functionPesquisar(){divListaItens.style.display="";document.manterCaracteristicaForm.action='../../../manterCaracteristicaAction.do?parAcao=pesquisar';document.manterCaracteristicaForm.submit();}functionsetaValor(valor){document.getElementById('codigoParametro').value=valor;}</SCRIPT></head><BODYclass="fnd1"><html:formaction="/manterCaracteristicaAction"><inputtype="hidden"name="codigoParametro"id="codigoParametro"><!-- ####### Tabela de Alinhamento ####### --><TABLEborder="0"cellpadding="0"cellspacing="0"width="748"><TR><TDcolspan="2"height="5"></TD></TR><TR><TDwidth="21"></TD><TD><!-- ####### Titulo ####### --><DIVid="divTitulo"style="width:100%"><p><FONTclass="ttl2">Manutenção</FONT><BR><FONTclass="ttl1">Manter Característica</FONT></p></DIV><!-- ####### Pesquisa ####### --><DIVid="divPesquisa"style="width:100%;padding-top:10px;"><TABLEborder="1"borderColor="#990000"borderColorDark="white"cellpadding="3"cellspacing="0"rules="rows"frame="below"class="tab1"width="100%"><TR><TDclass='ttltab1'colspan=8align='middle'>Opções de Pesquisa</TD></TR><TR><TDwidth="100"class='txt1'><b>Característica:</b></TD><TD><html:textproperty="nome"styleClass="txt1"size="40"maxlength="40"/></TD><TDwidth="60"class='txt1'><b>Situação:</b></TD><TD><html:selectproperty="ativo"styleClass="frmCmb1"><html:optionvalue="T">Todos</html:option><html:optionvalue="A">Ativo</html:option><html:optionvalue="I">Inativo</html:option></html:select></TD></TR></TABLE></DIV><!-- ####### LISTA DE ITENS ####### --><DIVid="divListaItens"style="width:100%;display: none; "><TABLEborder="1"borderColor="#990000"borderColorDark="white"cellpadding="3"cellspacing="0"rules="rows"frame="below"class="tab1"width="100%"><TRalign="center"><TDcolspan="4"class="ttlTab1">Características</TD></TR><TRalign="center"><TDwidth="20"class="ttlTab2"> </TD><TDclass="ttlTab2"align="left"><B>Característica</B></TD><TDwidth="150"class="ttlTab2"><B>Situação</B></TD><TDwidth="10"class="ttlTab2"> </TD></TR></TABLE><DIVid="divScroll"style="height:140px"><TABLEborder="1"borderColor="#990000"borderColorDark="white"cellpadding="3"cellspacing="0"rules="rows"frame="below"class="tab1"width="100%"><logic:presentname="lista"><logic:iteratename="lista"id="conteudo"><TRalign="center"><TDwidth="20"class="txtTab1"><inputtype="radio"name="itemSelecao"id="<bean:write property="codigo"name="conteudo"/>" value="radiobutton" class="frmTxt1" onclick="setaValor('<bean:writeproperty="codigo"name="conteudo"/>')">
</TD><TDclass="txtTab1"align="left"><bean:writeproperty="nome"name="conteudo"/></TD><TDwidth="150"class="txtTab1"><bean:writeproperty="descricaoAtivo"name="conteudo"/></TD></TR></logic:iterate></logic:present></TABLE></DIV></DIV><!-- ####### BOTOES ####### --><DIVid="divBotoes"><DIVid="botaoIncluir"><INPUTtype="Button"id="btoIncluir"name="btoIncluir"value="incluir"class="bto1"onclick="Incluir()"></DIV><DIVid="botaoAlterar"style="display:none"><INPUTtype="Button"id='btoAlterar'name='btoAlterar'value="alterar"class="bto1"onclick="Alterar()"></DIV><DIVid="botaoExcluir"style="display:none"><INPUTtype="Button"id='btoExcluir'name='btoExcluir'value="excluir"class="bto1"onclick="Excluir()"></DIV><DIVid="botaoPesquisar"><INPUTtype=buttonclass=bto1Value='pesquisar'id='bt_pesquisar'name='bt_pesquisar'align='left'onClick='Pesquisar()'></DIV></DIV></TD></TR><logic:presentname="lista"><logic:notEmptyname="lista"><script>divListaItens.style.display="";document.getElementById("botaoExcluir").style.display="";document.getElementById("botaoAlterar").style.display="";</script></logic:notEmpty></logic:present><logic:notPresentname="lista"><logic:emptyname="lista"><script>divListaItens.style.display="none";document.getElementById("botaoExcluir").style.display="none";document.getElementById("botaoAlterar").style.display="none";</script></logic:empty></logic:notPresent></TABLE></html:form></body><logic:presentname="mensagem"><script>alert('<bean:write name="mensagem" />')</script></logic:present></html:html>
E ocorre a exception
[code]
[Erro de Servlet]-[Request[/manterCaracteristicaAction] does not contain handler parameter named 'parAcao'. This may be caused by whitespace in the label text.]: javax.servlet.ServletException: Request[/manterCaracteristicaAction] does not contain handler parameter named 'parAcao'. This may be caused by whitespace in the label text.
Z
zezinho
Pessoal meio consegui resolver adicionando esta linha no meu form