1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.ajax;
18
19 import java.io.Reader;
20 import java.io.Writer;
21
22 import org.apache.velocity.app.VelocityEngine;
23 import org.apache.velocity.context.Context;
24
25 /***
26 * Response object used for AJAX services.
27 *
28 * @author <href a="mailto:weaver@apache.org">Scott T. Weaver</a>
29 *
30 */
31 public class AJAXResponseImpl implements AJAXResponse
32 {
33
34 private Context context;
35 private VelocityEngine engine;
36 private Reader template;
37 private Writer output;
38
39 public AJAXResponseImpl(Context context, VelocityEngine engine, Reader template, Writer output)
40 {
41 this.context = context;
42 this.engine = engine;
43 this.template = template;
44 this.output = output;
45 }
46
47
48
49
50 public void complete() throws AJAXException
51 {
52 try
53 {
54 engine.evaluate(context, output, "AJAX processor", template);
55 }
56 catch (Exception e)
57 {
58 throw new AJAXException("Failed to render velocity xml template: "+e.getMessage(), e);
59 }
60
61 }
62
63
64
65 }