Hi !
I am developing a webbased
struts application.
Due to changes in struts version 1.2 an derros we get (ClassCastException in ErrorsTag.java), I decided to change the Actions from ActionErrors to ActionMessages.
When I try with some validation and database erros, the AxctrionMessages object will be filled correctly.
But when I want to display them, nothing is displayed.
This is my source code:
AbstractAction:
protected void setActionMessages(ActionMessages messagesToAdd, HttpServletRequest request) {
if((messagesToAdd != null) && (messagesToAdd.size() > 0)){
saveMessages(request, actionMessagesToAdd);
}
else return;
}
Action:
ActionMessages actionMessages = null;
try {
actionMessages = form.validateCustom(mapping, request);
if (actionMessages!=null && !actionMessages.isEmpty()) {
setActionMessages(actionMessages, request); //Here I use the abstract method
return findActionForward(mapping, form.getActionForward());
}
...
actionMessages = prepareData(data, request);
if ((actionMessages != null) && (actionMessages.size() > 0)){
saveMessages(request, actionMessages);
return findActionForward(mapping, form.getActionForward());
}
else {
actionMessages = checkData(data);
}
if ((actionMessages != null) && (actionMessages.size() > 0)){
saveMessages(request, actionMessages);
return findActionForward(mapping, form.getActionForward());
}
else {
actionMessages = validateSpecial(data, request);
}
and so on...
In the
jsp, I have:
<logic:messagesPresent>
<h3>Errors:</h3>
<html:messages id="msg">
<bean:write name="msg"/>
<br>
</html:messages>
</logic:messagesPresent>
For example, when the method "prepareData();" gets an erro, it will be hold in the actionMessages object.
Thats ok.
This means, the saveMessages() method will be called.
After that the "findActionForward()" method will be called an the jsp will be shown.
Now I would expect to see the messages in the header of the jsp.
But I still see the same JSP like before, no error message etc.
What I am doing wrong ???
Please help !
best regards
Michael