01: /*
02: * Created on 18 Jul 2007
03: */
04: package uk.org.ponder.rsf.viewstate.support;
05:
06: import uk.org.ponder.reflect.ReflectiveCache;
07: import uk.org.ponder.rsf.viewstate.SiteMap;
08: import uk.org.ponder.rsf.viewstate.ViewParameters;
09: import uk.org.ponder.rsf.viewstate.ViewParamsReceiver;
10:
11: /** A utility class to allow views without producers to easily register
12: * their ViewParameters types using a Spring definition (alternative was the
13: * use of {@link SiteMap}).
14: * @author Antranig Basman (antranig@caret.cam.ac.uk)
15: *
16: */
17:
18: public class ViewParamsRegistrar {
19: private ViewParamsReceiver vpreceiver;
20: private ReflectiveCache reflectiveCache;
21:
22: public void setReflectiveCache(ReflectiveCache reflectiveCache) {
23: this .reflectiveCache = reflectiveCache;
24: }
25:
26: public void setViewID(String viewID) {
27: this .viewID = viewID;
28: }
29:
30: public void setViewParamsClass(Class viewParamsClass) {
31: this .viewParamsClass = viewParamsClass;
32: }
33:
34: public void setViewParametersReceiver(ViewParamsReceiver vpreceiver) {
35: this .vpreceiver = vpreceiver;
36: }
37:
38: private String viewID;
39:
40: private Class viewParamsClass;
41:
42: public void init() {
43: ViewParameters viewparams = (ViewParameters) reflectiveCache
44: .construct(viewParamsClass);
45: vpreceiver.setViewParamsExemplar(viewID, viewparams);
46: }
47: }
|