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.components;
19:
20: import java.io.IOException;
21: import java.io.Writer;
22: import java.util.*;
23: import de.finix.contelligent.action.Parameter;
24: import de.finix.contelligent.*;
25: import de.finix.contelligent.render.Renderable;
26: import de.finix.contelligent.render.Renderer;
27: import de.finix.contelligent.render.ParameterDescription;
28: import de.finix.contelligent.logging.LoggingService;
29:
30: /**
31: * A {@link Page} with no content definining a {@link Renderer} with no
32: * parameters which simply renders the result of an action. The result of the
33: * action is searched in the path defined by property <tt>actionResultPath</tt>.
34: */
35: public class ActionResultRenderer extends AbstractComponent implements
36: Renderable, Renderer, MenuEntry {
37: final static private org.apache.log4j.Logger log = LoggingService
38: .getLogger(ActionResultRenderer.class);
39:
40: private ComponentPath actionResultPath;
41:
42: public void setActionResultPath(ComponentPath path) {
43: actionResultPath = path;
44: }
45:
46: public ComponentPath getActionResultPath() {
47: return actionResultPath;
48: }
49:
50: public ParameterDescription[] getParameterDescription() {
51: return null;
52: }
53:
54: public Collection getSensitiveCategories() {
55: return Collections.EMPTY_SET;
56: }
57:
58: public Renderer getRenderer() {
59: return this ;
60: }
61:
62: public void render(Writer writer, Map parameterMap,
63: CallData callData) throws IOException {
64: try {
65: Parameter result = (Parameter) callData.getActualManager()
66: .getComponent(actionResultPath, callData);
67: Object actionResult = result.getObject(callData);
68: if (log.isDebugEnabled())
69: log.debug("'" + this
70: + "':render() - ... rendering result '"
71: + actionResult + "' ...");
72: writer
73: .write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
74: writer.write(actionResult.toString());
75: } catch (ComponentNotFoundException e) {
76: throw new IOException(
77: "Could not find action-result to render (in path '"
78: + actionResultPath + "')");
79: }
80: }
81:
82: public String getDefaultEnvironment() {
83: return "default";
84: }
85:
86: }
|