You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by omidh <om...@gmx.de> on 2007/05/10 08:45:11 UTC
Re: ValueBinding throw a servlet (solved)
Hi again,
I solved the problem.
for the intressted reader ;) :
protected FacesContext getFacesContext(HttpServletRequest request,
HttpServletResponse response) {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext == null) {
FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder
.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory
.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
facesContext = contextFactory.getFacesContext(request.getSession()
.getServletContext(), request, response, lifecycle);
}
return facesContext;
}
reagards Omid
omidh wrote:
>
> Hi all,
>
> I wrote a servlet for File Download. I am developing a portlet and the
> download is from a DB.
> So when I am in the servlet doGet() and try to receive a bean from the
> FacesContext
> I get a NullPointerException, here the code:
>
> FacesContext fctx = FacesContext.getCurrentInstance();
> //DetailsBean bean =
> (DetailsBean)fctx.getApplication().getVariableResolver().resolveVariable(fctx,
> "detailsBean");
> ValueBinding bind = FacesContext.getCurrentInstance().getApplication().
> createValueBinding("#{detailsBean}");
> DetailsBean bean = (DetailsBean)bind.getValue(fctx);
>
> the faces-config Entry:
>
> <managed-bean>
> <managed-bean-name>detailsBean</managed-bean-name>
>
> <managed-bean-class>main.org.jboss.portlet.milestone.jsf.bean.DetailsBean</managed-bean-class>
> <managed-bean-scope>request</managed-bean-scope>
> <managed-property>
> <property-name>facadeService</property-name>
>
> <property-class>main.org.jboss.portlet.milestone.jsf.facade.FacadeService</property-class>
> <value>#{facadeService}</value>
> </managed-property>
> <managed-property>
> <property-name>editId</property-name>
> <value>#{editId}</value>
> </managed-property>
> </managed-bean>
>
> so have to say that my FacesContext is null... but why?
> any ideas?
>
> thanks in advance,
> Omid
>
--
View this message in context: http://www.nabble.com/ValueBinding-throw-a-servlet-tf3719784.html#a10407990
Sent from the MyFaces - Users mailing list archive at Nabble.com.