Entao nbluis , não sei pq o jsf ou o seam estão interpretando de maneira incorreta caracteres como > ou < , somente funciona com o != mesmo, de repente eu preciso utilizar um > ou < , vou fazer esse teste depois já que testei o javascript todo e está funcionando.
Fiz algumas alterações e mudei ele para:
var listaBotoes = new Array ();
var botaoJaFoiClicado = false ;
function desabilitarBotaoSubmit ( button , form ) {
var i = 0 ;
var botoes = listaBotoes . toString ();
var existeBotaoArray = botoes . match ( button . name );
if ( existeBotaoArray == null ) {
if ( listaBotoes . length == 0 ) {
listaBotoes [ 0 ] = button . name ;
} else if ( listaBotoes . length == 1 ) {
listaBotoes [ 1 ] = button . name ;
} else if ( listaBotoes . length == 2 ) {
listaBotoes [ 2 ] = button . name ;
}
}
for ( i = 0 ; i != listaBotoes . length ; i ++ ) {
if ( listaBotoes [ i ] == button . name ) {
if ( botaoJaFoiClicado == false ) {
botaoJaFoiClicado = true ;
button . value = 'Aguarde!' ;
button . disable = true ;
document . forms [ form ] . submit ();
return true ;
} else {
alert ( "Aguarde!" );
return false ;
}
}
}
}
Essa função funciona perfeitamente para quem quiser utilizar JSF e não permitir que seja realizado um duplo clique e ainda adiciona todos os botões já clicados.
Só estou com uma dúvida: existe alguma outra maneira de eu adicionar objetos no array sem precisar passar o número da posição? Pq tenho páginas que tem uma porrada de botões e fica complicado criar outro javascript só para isso! hehe
var listaBotoes = new Array ();
var botaoJaFoiClicado = false ;
var contadorBotoes = 0 ;
function desabilitarBotaoSubmit ( button , form ) {
var i = 0 ;
var botoes = listaBotoes . toString ();
var existeBotaoArray = botoes . match ( button . name );
if ( existeBotaoArray == null ) {
listaBotoes [ contadorBotoes ] = button . name ;
contadorBotoes ++ ;
}
for ( i = 0 ; i != listaBotoes . length ; i ++ ) {
if ( listaBotoes [ i ] == button . name ) {
if ( botaoJaFoiClicado == false ) {
botaoJaFoiClicado = true ;
button . value = 'Aguarde!' ;
button . disable = true ;
document . forms [ form ] . submit ();
return true ;
} else {
alert ( "Aguarde!" );
return false ;
}
}
}
}
Essa seria a melhor maneira ou tem alguma outra mais elegante?
[]'s
Após esses ajustes, existem certos botões que estão me lançando a exceção:
2008 -04-01 10 : 29 : 58 , 359 INFO [ javax . enterprise . resource . webcontainer . jsf . lifecycle ] WARNING : FacesMessage ( s ) have been enqueued , but may not have been displayed .
sourceId = null [ severity = ( WARN 1 ), summary = ( The conversation ended , timed out or was processing another request ), detail = ( The conversation ended , timed out or was processing another request )]
2008 -04-01 10 : 29 : 58 , 593 WARN [ javax . enterprise . resource . webcontainer . jsf . lifecycle ] executePhase ( RENDER_RESPONSE 6 , com . sun . faces . context . FacesContextImpl @12 ad9ec ) threw exception
javax . faces . FacesException
at com . sun . faces . lifecycle . RenderResponsePhase . execute ( RenderResponsePhase . java : 135 )
at com . sun . faces . lifecycle . LifecycleImpl . phase ( LifecycleImpl . java : 251 )
at com . sun . faces . lifecycle . LifecycleImpl . render ( LifecycleImpl . java : 144 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 245 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 290 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . jboss . seam . web . ExceptionFilter . doFilter ( ExceptionFilter . java : 57 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 235 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . jboss . web . tomcat . filters . ReplyHeaderFilter . doFilter ( ReplyHeaderFilter . java : 96 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 235 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 230 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 175 )
at org . jboss . web . tomcat . security . SecurityAssociationValve . invoke ( SecurityAssociationValve . java : 179 )
at org . jboss . web . tomcat . security . JaccContextValve . invoke ( JaccContextValve . java : 84 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 128 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 104 )
at org . jboss . web . tomcat . service . jca . CachedConnectionValve . invoke ( CachedConnectionValve . java : 157 )
at org . apache . catalina . authenticator . SingleSignOn . invoke ( SingleSignOn . java : 393 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 109 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 241 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 844 )
at org . apache . coyote . http11 . Http11Protocol$Http11ConnectionHandler . process ( Http11Protocol . java : 580 )
at org . apache . tomcat . util . net . JIoEndpoint$Worker . run ( JIoEndpoint . java : 447 )
at java . lang . Thread . run ( Thread . java : 595 )
Caused by : ClientAbortException : javax . net . ssl . SSLException : Connection has been shutdown : javax . net . ssl . SSLException : java . net . SocketException : Software caused connection abort : socket write error
Existe alguma maneira de evitar isso? E isso só ocorre na primeira vez que é realizado o duplo clique, nas próximas funcionam normalmente e independente de quantos cliques forem efetuados.
[]'s