01: /*
02: * Created on 11-Jan-2006
03: */
04: package uk.org.ponder.rsf.viewstate.support;
05:
06: import java.util.Iterator;
07:
08: import uk.org.ponder.rsf.viewstate.SiteMap;
09: import uk.org.ponder.rsf.viewstate.ViewParameters;
10: import uk.org.ponder.rsf.viewstate.ViewParamsReceiver;
11: import uk.org.ponder.springutil.XMLFactoryBean;
12:
13: /** A Spring FactoryBean that will embody a BasicViewParametersParser
14: * object based on the contents of an XML-formatted sitemap file.
15: *
16: * @author Antranig Basman (amb26@ponder.org.uk)
17: */
18:
19: public class XMLSiteMapLoader extends XMLFactoryBean {
20: private ViewParamsReceiver vpreceiver;
21:
22: public XMLSiteMapLoader() {
23: setObjectType(SiteMap.class);
24: }
25:
26: public Class getObjectType() {
27: return SiteMap.class;
28: }
29:
30: public void setViewParametersReceiver(ViewParamsReceiver vpreceiver) {
31: this .vpreceiver = vpreceiver;
32: }
33:
34: public Object getObject() throws Exception {
35: SiteMap sitemap = (SiteMap) super .getObject();
36: for (Iterator vpit = sitemap.view.keySet().iterator(); vpit
37: .hasNext();) {
38: String viewid = (String) vpit.next();
39: ViewParameters viewparams = (ViewParameters) sitemap.view
40: .get(viewid);
41: vpreceiver.setViewParamsExemplar(viewid, viewparams);
42: }
43: return sitemap;
44: }
45: }
|