01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.action;
19:
20: import java.io.IOException;
21:
22: import de.finix.contelligent.CallData;
23: import de.finix.contelligent.exception.ContelligentException;
24:
25: public class OrderErrorMessages extends ErrorMessage implements
26: Constants {
27:
28: private String prefix;
29:
30: private String postfix;
31:
32: public void setPrefix(String value) {
33: prefix = value;
34: }
35:
36: public String getPrefix() {
37: return prefix;
38: }
39:
40: public void setPostfix(String value) {
41: postfix = value;
42: }
43:
44: public String getPostfix() {
45: return postfix;
46: }
47:
48: // XXX: requires custom renderer or similar handling
49: public String getString(CallData callData)
50: throws ContelligentException, IOException {
51: String message = super .getString(callData);
52: if (message.length() == 0) {
53: return "";
54: } else {
55: return getPrefix()
56: + String.valueOf(getList(callData).addMessage(
57: message)) + getPostfix();
58: }
59: }
60:
61: public ErrorMessageList getList(CallData callData) {
62: ErrorMessageList answer;
63:
64: if (scopeSession()) {
65: answer = (ErrorMessageList) callData
66: .getSessionAttribute(ORDERED_ERROR_STORE);
67: } else {
68: answer = (ErrorMessageList) callData
69: .getRequestAttribute(ORDERED_ERROR_STORE);
70: }
71:
72: if (answer == null) {
73: answer = new ErrorMessageList();
74: if (scopeSession()) {
75: callData.setSessionAttribute(ORDERED_ERROR_STORE,
76: answer);
77: } else {
78: callData.setRequestAttribute(ORDERED_ERROR_STORE,
79: answer);
80: }
81: }
82: return answer;
83: }
84:
85: }
|