| Autor |
Mensagem |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 07/04/2008 10:12:49
|
jovijesc
JavaChild
Membro desde: 04/09/2007 12:30:08
Mensagens: 148
Offline
|
Dae galera.. estou desenvolvendo um sistema web utilizando jsp, Servles, ajax.. o básico mesmo... eu queria saber como que vcs fazem o controle por exemplo em um formulário.... dae o cara clica no submit e depois clica de novo.... nesse caso será cadastrado dois registros... , a pergunta é.. como evitar que o usuário submeta o formulário duas vezes??
Abraço!
This message was edited 1 time. Last update was at 07/04/2008 11:35:39
|
|
|
 |
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 07/04/2008 10:32:11
|
Guitar_Men
JavaEvangelist
![[Avatar]](/images/avatar/40dcade0986efb728091792e3c538e6c.jpg)
Membro desde: 21/02/2008 10:01:31
Mensagens: 463
Offline
|
Faz uma função em javascript que desabilite o botão enviar do seu form quando ele clicar...
|
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 07/04/2008 10:36:20
|
humberto.lima
Debugger
Membro desde: 18/12/2006 20:16:25
Mensagens: 58
Offline
|
Tem duas formas de formas de fazer (devem haver mais):
1 - Desabilitar o botão qndo o usuário clicar.
2 - Colocar na sessao do usuário um atributo e passar para o formulario, qndo o formulario for submetido vc confere esse atributo e muda-o. Caso seja submetido duas vezes o mesmo formulario esses atributos serao diferentes( formulario e sessao) entao voce sabera q o formulario nao corresponde ao mais atualizado, ou seja, ja foi recebido.
ver: synchronizer token.
Duplicate Form Submissions
Users working in a browser client environment may use the Back button and inadvertently resubmit the same form they had previously submitted, possibly invoking a duplicate transaction. Similarly, a user might click the Stop button on the browser before receiving a confirmation page, and subsequently resubmit the same form. In most cases, we want to trap and disallow these duplicate submissions, and using a controlling servlet provides a control point for addressing this problem.
Synchronizer (or Déjà vu) Token
This strategy addresses the problem of duplicate form submissions. A synchronizer token is set in a user's session and included with each form returned to the client. When that form is submitted, the synchronizer token in the form is compared to the synchronizer token in the session. The tokens should match the first time the form is submitted. If the tokens do not match, then the form submission may be disallowed and an error returned to the user. Token mismatch may occur when the user submits a form, then clicks the Back button in the browser and attempts to resubmit the same form.
On the other hand, if the two token values match, then we are confident that the flow of control is exactly as expected. At this point, the token value in the session is modified to a new value and the form submission is accepted.
You may also use this strategy to control direct browser access to certain pages, as described in the sections on resource guards. For example, assume a user bookmarks page A of an application, where page A should only be accessed from page B and C. When the user selects page A via the bookmark, the page is accessed out of order and the synchronizer token will be in an unsynchronized state, or it may not exist at all. Either way, the access can be disallowed if desired.
Please refer to "Introduce Synchronizer Token" in the "Presentation Tier Refactorings" section, p. 77 for an example of this strategy.
[]´s
Humberto Lima
This message was edited 1 time. Last update was at 07/04/2008 10:42:47
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 07/04/2008 10:44:26
|
psandrelli
JavaChild
![[Avatar]](/images/avatar/2f93b699c738691d0b53d82ed1e25817.jpg)
Membro desde: 17/05/2007 15:39:35
Mensagens: 128
Localização: Belo Horizonte-MG
Offline
|
Quando o cara fazer o submit, se tudo estiver ok, vc o redireciona para uma tela de sucesso. Após isso, ele clica em um botão para voltar, e vc devolve o formulário vazio, ou para uma outra tela.
Isso é uma opção.
|
boolean euEstiverVivo = true;
do {
System.out.println("Ozzy no Brasil...eu fui! (SP-área vip)");
} while (euEstiverVivo);
Pablo Sandrelli |
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 07/04/2008 11:02:43
|
Marky.Vasconcelos
Moderador
![[Avatar]](/images/avatar/04940fadf3702cbd84b7a48161037c4f.png)
Membro desde: 11/04/2007 18:18:20
Mensagens: 5932
Localização: São Paulo/SP
Offline
|
Evitar ele clicar duas vezes seguidas no submit??
Crie uma função JavaScript e chame no botão quando cicado
no meu caso eu tenho esse:
|
Facebook @MarkyHitchhiker +Mark WP: MarkyTech's
Projects:
Android Roadmap - Aprenda Android do inicio (Java é o unico pre-requisito)
Towel ( ObjectTableModel & Swing & Utils )
Tower Defense Game - Java2D [Open-Source] [How-to-play]
EVGD: Programação de jogos (links) Ponto V! - Desenvolvimento de jogos para indies, curiosos e profissionais
DefaultTableModel?! PARE! Não faça isso! Faça melhor!
Dicas: Faça perguntas inteligentes! ; MigLayout ; GridBagLayout (Joke)
Develop games is fantastic, with words you can make worlds!!!
DON'T PANIC!
MarkyHitchhiker's Blog! |
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 07/04/2008 11:34:41
|
jovijesc
JavaChild
Membro desde: 04/09/2007 12:30:08
Mensagens: 148
Offline
|
Valeu galera... me ajudaram muito!!
Abraço!!
|
|
|
 |
|
|