Struts

1 resposta
R

Estou usando Struts , e tudo esta funcionando ok, mas nao consigo mostrar as mensagens de erro.

Action

}
	    catch (IllegalArgumentException ex)
	    {
	    	
	        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.insert.usuario.formulario"));                	
	    	
	    }
	    catch (SQLException e) {
	        if (e.getErrorCode() == 1062) {
	            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.idUsuario.duplicateKey"));
	        }
	        else {
	            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.insert.novo.usuario"));
	        }
	    }

error.jsp


<html:link page="/Welcome.do">Página Inicial</html:link>
</center>

1 Resposta

D

Cara tenta concentrar as mensagens de erro nos teus forms.

public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1)
	{
		ActionErrors errors = new ActionErrors();
		
		int data = 0;
		
		if(dataReuniao!=null)
		{
			data = Integer.parseInt(dataReuniao.substring(6));
			try
			{
				if(ReuniaoCelulaModel.verificaReuniao(dataReuniao, codCelula))
					errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage("reuniaoCelulaForm.dataExistente.display"));	
				if(data<2005)
					errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage("reuniaoCelulaForm.dataNaoValida.display"));
				if(dataReuniao.equalsIgnoreCase("00/00/0000"))
					errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage("reuniaoCelulaForm.dataNaoValida.display"));
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}	
		
		
		
		return errors;
	}

E utiliza o método validate pra captar, tratar e enviar erros. Além de derivar teu form de ValidatorForm.

public class XXXXForm extends ValidatorForm

:slight_smile:

Criado 22 de maio de 2006
Ultima resposta 23 de mai. de 2006
Respostas 1
Participantes 2