The list of success messages (both single and list messages) is now pulled from the services invoked thru the service-multi handler so that the messages can be shown on screen: duplicated messages are not added to the output list.

git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@469851 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacopo Cappellato
2006-11-01 10:44:04 +00:00
parent cbceecbf87
commit 1c81b724ef
@@ -150,8 +150,9 @@ public class ServiceMultiEventHandler implements EventHandler {
String messagePrefixStr = UtilProperties.getMessage("DefaultMessages", "service.message.prefix", locale);
String messageSuffixStr = UtilProperties.getMessage("DefaultMessages", "service.message.suffix", locale);
// prepare the error message list
// prepare the error message and success message lists
List errorMessages = FastList.newInstance();
List successMessages = FastList.newInstance();
// big try/finally to make sure commit or rollback are run
boolean beganTrans = false;
@@ -296,7 +297,23 @@ public class ServiceMultiEventHandler implements EventHandler {
if (UtilValidate.isNotEmpty(errorMessage)) {
errorMessages.add(errorMessage);
}
// get the success messages
if (!UtilValidate.isEmpty((String)result.get(ModelService.SUCCESS_MESSAGE))) {
String newSuccessMessage = (String)result.get(ModelService.SUCCESS_MESSAGE);
if (!successMessages.contains(newSuccessMessage)) {
successMessages.add(newSuccessMessage);
}
}
if (!UtilValidate.isEmpty((List)result.get(ModelService.SUCCESS_MESSAGE_LIST))) {
List newSuccessMessages = (List)result.get(ModelService.SUCCESS_MESSAGE_LIST);
for (int j = 0; j < newSuccessMessages.size(); j++) {
String newSuccessMessage = (String)newSuccessMessages.get(j);
if (!successMessages.contains(newSuccessMessage)) {
successMessages.add(newSuccessMessage);
}
}
}
// set the results in the request
if ((result != null) && (result.entrySet() != null)) {
Iterator rmei = result.entrySet().iterator();
@@ -339,6 +356,9 @@ public class ServiceMultiEventHandler implements EventHandler {
Debug.logError(e, "Could not commit transaction", module);
throw new EventHandlerException("Commit transaction failed");
}
if (successMessages.size() > 0) {
request.setAttribute("_EVENT_MESSAGE_LIST_", successMessages);
}
returnString = "success";
}
}