HttpServletRequest request, HttpServletResponse response)
throws Exception {
// Get all of the options from the resource bundle
List options = new ArrayList();
MessageResources resources = null;
String bundle = request.getParameter("bundle");
String propertyPrefix = request.getParameter("propertyPrefix");
String type = request.getParameter("type");
if (type == null) {
type = "message";
}
String arg0 = request.getParameter("arg0");
boolean decorated = true;
String align = "center";
Locale locale = (Locale)request.getSession().getAttribute(Globals.LOCALE_KEY);
// parameter
// ="administration,deletePropertyProfile,yes=/updatePropertyProfile.do?action=delete,no="
if (mapping.getParameter() != null
&& !mapping.getParameter().equals("")) {
StringTokenizer t = new StringTokenizer(mapping.getParameter(), ",");
if (t.hasMoreTokens()) {
type = t.nextToken();
}
// TODO this is a hack to get the extension store agreement aligning
// left, sort it out properly!
if (type.startsWith("align=")) {
int idx = type.indexOf('=');
align = type.substring(idx + 1);
type = t.nextToken();
}
if (t.hasMoreTokens()) {
decorated = t.nextToken().equalsIgnoreCase("true");
}
if (t.hasMoreTokens()) {
bundle = t.nextToken();
}
if (t.hasMoreTokens()) {
propertyPrefix = t.nextToken();
}
resources = getResources(request, bundle);
if (resources == null) {
throw new Exception("Could not find resource bundle " + bundle);
}
while (t.hasMoreTokens()) {
String option = t.nextToken();
options.add(getOption(locale, option, propertyPrefix, request,
resources));
}
} else {
resources = getResources(request, bundle);
if (resources == null) {
throw new Exception("Could not find resource bundle " + bundle);
}
String[] optionValues = request.getParameterValues("option");
if (options != null) {
for (int i = 0; i < optionValues.length; i++) {
options.add(getOption(locale, optionValues[i], propertyPrefix,
request, resources));
}
}
}
// Get the title text and the description
String title = resources.getMessage(locale, propertyPrefix + ".title");
String subtitle = resources.getMessage(locale, propertyPrefix + ".subtitle");
String message = resources
.getMessage(locale, propertyPrefix + ".message", arg0);
// Initialise the form
ConfirmForm confirmForm = (ConfirmForm) form;
confirmForm.initialize(type, title, subtitle, message, options,
decorated, align, arg0);
// If this confirmation is the result on an exception then build up the
// exception text
Throwable exception = type.equals(ConfirmForm.TYPE_EXCEPTION) ? (Throwable) request
.getSession().getAttribute(Constants.EXCEPTION)
: null;
request.getSession().removeAttribute(Constants.EXCEPTION);
if (exception != null) {
StringBuffer mesgBuf = new StringBuffer();
StringBuffer traceBuf = new StringBuffer();
Throwable ex = exception;
while (ex != null) {
String mesg = ex.getMessage();
if (mesg != null) {
mesg = mesg.trim();
if (!mesg.endsWith(".")) {
mesg += ".";
}
if (mesgBuf.length() == 0) {
mesgBuf.append('\n');
}
mesgBuf.append(mesg);
}
StringWriter sw = new StringWriter();
ex.printStackTrace(new PrintWriter(sw));
if (traceBuf.length() == 0) {
traceBuf.append("\n");
}
traceBuf.append(sw.toString());
ex = ex.getCause();
}
// If this is a code exception we can get the localised messages
if (exception instanceof CoreException) {
CoreException ce = (CoreException) exception;
MessageResources mr = CoreUtil.getMessageResources(request
.getSession(), ce.getBundle());
if (mr != null) {
mesgBuf.append(" ");
mesgBuf.append(mr.getMessage((Locale) request
.getSession().getAttribute(Globals.LOCALE_KEY), ce
.getBundleActionMessage().getKey(), ce
.getBundleActionMessage().getArg0(), ce
.getBundleActionMessage().getArg1(), ce
.getBundleActionMessage().getArg2(), ce