01: /* ContextUtil.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: 2007/8/22 11:16:22 AM 2007, Created by Dennis.Chen
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.jsf.zul.util;
20:
21: import javax.faces.context.FacesContext;
22:
23: /**
24: * a utitlity for JSF context
25: * @author Dennis.Chen
26: */
27: public class ContextUtil {
28:
29: /**
30: * get Bean from current faces context;
31: * @param name bean name
32: * @return instance of bean by bean name.
33: */
34: public static Object getBean(String name) {
35: FacesContext context = FacesContext.getCurrentInstance();
36: Object obj = context.getApplication().getVariableResolver()
37: .resolveVariable(context, name);
38: return obj;
39: }
40: }
|