On 8/28/05, ir. ing. Jan Dockx <[EMAIL PROTECTED]> wrote: > Good point, I think, and no, I can't think of a rationale. >
The key issue is that expression evaluation occurs with respect to a context ... specifically, the FacesContext for the current request, which contains internal references to (in a webapp) a ServletContext, a ServletRequest, and a ServletResponse. There can't be such a "real" object at application startup time, because there is no request in place. > You could work around the limitation by initializing the objects you > need in a servlet context listener though, and store them in > application scope yourself. You are not using the managed bean (~ IoC) > mechanism then though. > > If, however, you just access the VariableResolver in your context > listener, the beans get initialized and get stored in the scope they > are defined for. > That won't necessarily be sufficient if your managed bean declaration has managed properties that are also initialized via value binding expressions. The JSF framework will be applying its usual expression evaluation facilities to that kind of an expression. An alternative that might work, though, is to construct a mock ExternalContext with only the ServletContext object, and no request and response, and then construct a mock FacesContext wrapping that. You should be able to evaluate expressions that don't attempt to access things from request or session scope. Craig

