Re: [S2] Validation error messages are not being cleared

2007-03-25 Thread Célio Cidral Junior

2007/3/25, Dave Newton <[EMAIL PROTECTED]>:

--- Célio Cidral Junior wrote:
Is it declared with scope="prototype"?


Oh noes! I fotgot about the scope! :-(

MY APOLOGIES! MY APOLOGIES!

Célio.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [S2] Validation error messages are not being cleared

2007-03-25 Thread Dave Newton
--- Célio Cidral Junior wrote:
> [S2 validation messages not being cleared]

You didn't include your Spring config for the action,
which is a lot more important than the getters and
setters.

Is it declared with scope="prototype"?

d.



 

Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.
http://farechase.yahoo.com/promo-generic-14795097

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[S2] Validation error messages are not being cleared

2007-03-25 Thread Célio Cidral Junior

An action has this validation config:




Campo obrigatório




Campo obrigatório


[a-z]+

Digite apenas letras minúsculas. Não são 
permitidos espaços,
números, nem caracteres acentuados.





The validation works fine, except that the field error messages are
not getting cleared when the user fills the fields correctly in the
second submit.

The procedure is:

1. Submit the form with all fields empty;

(Struts shows the validation error messages correctly.)

2. Fill all fields with good values and submit again.

(Struts duplicates the messages right above the previous ones.)

And as you submit the form over and over again, Struts keeps
invalidating the fields, duplicating the error messages. I'm using
Struts 2.0.6.

-8-<- struts.xml (excerpt for that action) -8-<-

 
/jsp/private/usuario-form.jsp
listaDeUsuarios


-8-<- the action -8-<-

public class UsuarioFormAction extends PrevaylerAction {
private static final long serialVersionUID = 1L;

private int id = 0;
private String nome;
private Perfil perfil;
private String identificacao;
private String senha;
private String confirmacaoDeSenha;

public Set getPerfis() {
return contexto().getPerfis();
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getNome() {
return nome;
}

public void setNome(String nome) {
this.nome = nome;
}

public int getPerfil() {
return perfil.getId();
}

public void setPerfil(int id) throws Exception {
PesquisaDePerfilPorIdQuery pesquisa = new 
PesquisaDePerfilPorIdQuery();

pesquisa.setId(id);

perfil = (Perfil) prevayler().execute(pesquisa);
}

public String getIdentificacao() {
return identificacao;
}

public void setIdentificacao(String identificacao) {
this.identificacao = identificacao;
}

public void setSenha(String senha) {
this.senha = senha;
}

public void setConfirmacaoDeSenha(String confirmacaoDeSenha) {
this.confirmacaoDeSenha = confirmacaoDeSenha;
}

public String input() throws Exception {
if (id != 0) {
PesquisaDeUsuarioPorIdQuery pesquisa = new 
PesquisaDeUsuarioPorIdQuery();

pesquisa.setId(id);

Usuario usuario = (Usuario) 
prevayler().execute(pesquisa);

if (usuario == null)
return ERROR;

nome = usuario.getNome();
perfil = usuario.getPerfil();
identificacao = usuario.getIdentificacao();
}

return INPUT;
}

public String salvar() throws Exception {
if (senha.compareTo(confirmacaoDeSenha) == 0) {
if (id == 0) {
if (senha.length() > 0)
criar();
else {
addActionMessage("Digite uma senha para o 
novo usuário.");
return INPUT;
}
} else
modificar();
} else {
addActionMessage("As senhas não conferem. Digite-as 
novamente.");
return INPUT;
}

return SUCCESS;
}

private void modificar() {
ModificacaoDeUsuarioTransaction modificacao = new
ModificacaoDeUsuarioTransaction();

modificacao.setId(id);
modificacao.setNome(nome);
modificacao.setPerfil(perfil);
modificacao.setIdentificacao(identificacao);

if (senha.length() > 0)
modificacao.setSenha(senha);

prevayler().execute(modificacao);
}

private void criar() throws Exception {