01: /* DelegatingVariableResolver.java
02: {{IS_NOTE
03: Purpose:
04:
05: Description:
06:
07: History:
08: Jul 25, 2007 10:03:38 AM , Created by Dennis Chen
09: }}IS_NOTE
10:
11: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
12:
13: {{IS_RIGHT
14: This program is distributed under GPL Version 2.0 in the hope that
15: it will be useful, but WITHOUT ANY WARRANTY.
16: }}IS_RIGHT
17: */
18: package org.zkoss.seam;
19:
20: import org.jboss.seam.jsf.ListDataModel;
21: import org.zkoss.xel.VariableResolver;
22:
23: /**
24: * A Variable Resolver to find variable from Seam's context.
25: *
26: * <br/>Configuration in zul file:<br/>
27: * <?variable-resolver class="org.zkforge.seam.DelegatingVariableResolver"?>
28: *
29: * @author Dennis.Chen
30: *
31: */
32: public class DelegatingVariableResolver implements VariableResolver {
33:
34: public DelegatingVariableResolver() {
35: }
36:
37: /**
38: * Get bean from Seam's context,<br/>
39: * If bean is a ListDataModel, then a {@link ListDataModelWrapper} which contains original bean will be return.
40: * This is for delegating JSF' DataModel to ZK's DataModel.
41: *
42: * @param name name of component
43: * @return bean of context.
44: */
45: public Object resolveVariable(String name) {
46: Object obj = ContextUtil.getBean(name);
47:
48: if (obj instanceof ListDataModel) {
49: return new ListDataModelWrapper((ListDataModel) obj);
50: }
51: return obj;
52: }
53:
54: }
|