01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: DwrRifePageNormalizer.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.engine.elements;
09:
10: import com.uwyn.rife.engine.ElementToService;
11: import com.uwyn.rife.engine.Site;
12: import org.directwebremoting.extend.PageNormalizer;
13:
14: /**
15: * Returns an element's reference ID according to the URL it was accessed with.
16: * This is needed for DWR reverse Ajax to work.
17: *
18: * @author Geert Bevin <gbevin[remove] at uwyn dot com>
19: */
20: class DwrRifePageNormalizer implements PageNormalizer {
21: private Site mSite;
22:
23: public DwrRifePageNormalizer(Site site) {
24: mSite = site;
25: }
26:
27: public String normalizePage(String unnormalized) {
28: ElementToService element_match = mSite
29: .findElementForRequest(unnormalized);
30: if (null == element_match) {
31: return unnormalized;
32: }
33:
34: return element_match.getElementInfo().getReferenceId();
35: }
36: }
|