|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.faces.el.VariableResolver
org.picocontainer.web.jsf.PicoVariableResolver
public class PicoVariableResolver
This is a variable resolver implementation for Java ServerFaces.
Add install this variable resolver by adding setting the application's variable resolver to org.picocontainer.web.jsf.NanoWarDelegatingVariableResolver. An example follows:
<faces-config>
<application>
<strong>
<variable-resolver>
org.picocontainer.web.jsf.NanoWarDelegatingVariableResolver
</variable-resolver>
</strong>
</application>
....
</faces-config>
Even though you are writing a backing bean, you can utilize PicoContainers CDI capabilities to the fullest. Example:
//Imports and variables...
public ListCheeseController(<strong>CheeseService service</strong>) {
this.service = service;
}
//The rest of the class.
(This assumes you have installed NanoWAR properly. Please see the NanoWAR documentation for specific instructions)
You need to name your services with the name you will be giving your Backing Bean. Example:
pico = builder.container(parent: parent) {
if(assemblyScope instanceof javax.servlet.ServletContext) {
// Application Services would go here.
} else if (assemblyScope instanceof javax.servlet.ServletRequest) {
<strong>addComponent(key: 'cheeseBean', class: 'org.picocontainer.web.samples.jsf.ListCheeseController')</strong>
}
}
Set the managed bean names in your faces-config to equal the names given to the backing beans in the nanowar composition script. Example:
<managed-bean>
<description>CDI Injected Bean</description>
<strong><managed-bean-name>cheeseBean</managed-bean-name></strong>
<managed-bean-class>
org.picocontainer.web.samples.jsf.CheeseController
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
Notice how the same names were used in the faces-config as in the nanowar configuration. When the JSF page asks for the bean named 'addCheeseBean', the Nano variable resolver will take that name and check nanocontainer for an object of that instance. If it finds one, it will send it back to the page.
Note:This class currently has only been tested using MyFaces. There are reports that this technique doesn't work on all reference implementation versions. We welcome success or failure feedback!
| Nested Class Summary | |
|---|---|
static class |
PicoVariableResolver.ServletFilter
|
| Constructor Summary | |
|---|---|
PicoVariableResolver(javax.faces.el.VariableResolver decorated)
Decorated Variable resolver. |
|
| Method Summary | |
|---|---|
protected javax.faces.el.VariableResolver |
getNested()
Retrieve the delegated value. |
protected org.picocontainer.PicoContainer |
getPicoContainer(javax.faces.context.FacesContext facesContext)
Tries to locate the nanocontainer first at request level, and then if it doesn't find it there. |
Object |
resolveVariable(javax.faces.context.FacesContext facesContext,
String name)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PicoVariableResolver(javax.faces.el.VariableResolver decorated)
decorated - | Method Detail |
|---|
protected javax.faces.el.VariableResolver getNested()
public Object resolveVariable(javax.faces.context.FacesContext facesContext,
String name)
resolveVariable in class javax.faces.el.VariableResolverfacesContext - name -
javax.faces.el.EvaluationExceptionVariableResolver.resolveVariable(javax.faces.context.FacesContext,
java.lang.String)protected org.picocontainer.PicoContainer getPicoContainer(javax.faces.context.FacesContext facesContext)
facesContext -
javax.faces.el.EvaluationException - if it cannot find a NanoWAR instance.
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||