01: /*
02: * Created on 2 Sep 2007
03: */
04: package uk.org.ponder.rsf.flow.support;
05:
06: import uk.org.ponder.beanutil.BeanModelAlterer;
07: import uk.org.ponder.mapping.DARList;
08: import uk.org.ponder.mapping.DARReceiver;
09: import uk.org.ponder.mapping.DataAlterationRequest;
10: import uk.org.ponder.messageutil.TargettedMessageList;
11: import uk.org.ponder.rsf.flow.ARIResult;
12: import uk.org.ponder.rsf.flow.ActionResultInterceptor;
13: import uk.org.ponder.rsf.viewstate.ViewParameters;
14: import uk.org.ponder.util.Logger;
15:
16: /** An interesting THING1 which does the work of allowing UIELBindings to be
17: * applied directly to outgoing URL state from an action cycle. It uses the
18: * intreresting strategy of being a DARReceiver, mapped to the path of the
19: * ARIResult, which intercepts requests to write to it and redirects them onto
20: * itself, to be replayed later during ARI2 execution time. With this bean,
21: * essentially all uses of ARI2 can actually be handled directly with bindings.
22: * @author Antranig Basman (antranig@caret.cam.ac.uk)
23: *
24: */
25:
26: public class ARIResultPenningReshaper implements DARReceiver,
27: ActionResultInterceptor {
28:
29: private DARList pent = new DARList();
30: private BeanModelAlterer darapplier;
31: private TargettedMessageList targettedMessageList;
32:
33: public void setBeanModelAlterer(BeanModelAlterer darapplier) {
34: this .darapplier = darapplier;
35: }
36:
37: public boolean addDataAlterationRequest(DataAlterationRequest toadd) {
38: pent.add(toadd);
39: return true;
40: }
41:
42: public void setTargettedMessageList(
43: TargettedMessageList targettedMessageList) {
44: this .targettedMessageList = targettedMessageList;
45: }
46:
47: public void interceptActionResult(ARIResult result,
48: ViewParameters incoming, Object actionReturn) {
49: if (!targettedMessageList.isError()) {
50: for (int i = 0; i < pent.size(); ++i) {
51: DataAlterationRequest dar = pent.DARAt(i);
52: try {
53: darapplier.applyAlteration(result, dar, null);
54: } catch (Exception e) {
55: Logger.log
56: .info(
57: "Error applying binding to outgoing URL state",
58: e);
59: }
60: }
61: }
62:
63: }
64:
65: }
|