Mensagens no Struts 1

2 respostas
L

Alguem tem algum artigo como utilizar o ActionMessage do Struts. Nao consigo chamar no jsp.

Minha Action

public class TesteAction extends DispatchAction {

public ActionForward inicio(ActionMapping map, ActionForm actionForm,
		HttpServletRequest request, HttpServletResponse response) {
	
	ActionMessages messages = new ActionMessages();
	ActionMessage msg = new ActionMessage("deu.certo");
	messages.add("deu.certo",msg);
	return map.findForward("sucesso");
}

}

Meu JSP

<%@ taglib uri="/tags/struts-bean" prefix=“bean” %>
<%@ taglib uri="/tags/struts-html" prefix=“html” %>
<%@ taglib uri="/tags/struts-logic" prefix=“logic” %>
html:html

Insert title here
<logic:messagesPresent name="deu.certo"	message="true">

	<html:messages name="deu.certo" id="message" message="true">
		<bean:write name="message" />
	</html:messages>

</logic:messagesPresent>
<h1>Teste de Mensagens</h1>

aplication.properties
deu.certo=Messagem de Sucesso!

2 Respostas

FilhoDoRei

Amigo posta seu codigo assim:

public class TesteAction extends DispatchAction { 

    public ActionForward inicio(ActionMapping map, ActionForm actionForm, 
                                           HttpServletRequest request, HttpServletResponse response) { 

        ActionMessages messages = new ActionMessages(); 
        ActionMessage msg = new ActionMessage("deu.certo"); 
        messages.add("deu.certo",msg); 
        return map.findForward("sucesso"); 
    } 

}
<%@ taglib uri="/tags/struts-bean" prefix="bean" %> 
<%@ taglib uri="/tags/struts-html" prefix="html" %> 
<%@ taglib uri="/tags/struts-logic" prefix="logic" %> 
<html:html> 
<head> 
<title>Insert title here</title> 
</head> 
<body> 

<logic:messagesPresent name="deu.certo" message="true"> 

<html:messages name="deu.certo" id="message" message="true"> 
<bean:write name="message" /> 
</html:messages> 

</logic:messagesPresent> 
<h1>Teste de Mensagens</h1> 
</body> 
</html:html> 


aplication.properties 
deu.certo=Messagem de Sucesso!

Fica mais facil de visualizar!

Falowsss

L

Estou com o mesmo problema. Coloco as mensagens porém não funciona…

Criado 19 de maio de 2008
Ultima resposta 16 de jun. de 2008
Respostas 2
Participantes 3