You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Dean Hiller <de...@xsoftware.biz> on 2006/04/13 13:37:44 UTC

difference between createValueBinding and resolveVariable

What is the different between the below snippets of code?  Is is true 
that they are exactly the same if projectBean is a managed bean?  If it 
is not a managed bean, then the first snippet would be creating a 
runtime managed bean(one that was not declared in faces-config.xml).

        ValueBinding bind = 
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{projectBean}");
        ProjectBean projBean = (ProjectBean)bind.getValue(ctx);

        Object obj = 
FacesContext.getCurrentInstance().getApplication().getVariableResolver()
            .resolveVariable(FacesContext.getCurrentInstance(), 
"projectBean");
        ProjectBean projBean = (ProjectBean)obj;

thanks,
dean



Re: difference between createValueBinding and resolveVariable

Posted by Pierpaolo Follia <pi...@wavegroup.it>.
There is no difference between the two snippets of code: when you create 
a ValueBinding you evaluate a whole EL. If you use the variable 
resolver, you are resolving the left part of an EL. In your example the 
EL #{projectBean} is exactly the left part of the EL.
There's difference only if you put a more complex EL in the first snippet.

Regards,
Pierpaolo

Dean Hiller wrote:
> What is the different between the below snippets of code?  Is is true 
> that they are exactly the same if projectBean is a managed bean?  If 
> it is not a managed bean, then the first snippet would be creating a 
> runtime managed bean(one that was not declared in faces-config.xml).
>
>        ValueBinding bind = 
> FacesContext.getCurrentInstance().getApplication().createValueBinding("#{projectBean}"); 
>
>        ProjectBean projBean = (ProjectBean)bind.getValue(ctx);
>
>        Object obj = 
> FacesContext.getCurrentInstance().getApplication().getVariableResolver()
>            .resolveVariable(FacesContext.getCurrentInstance(), 
> "projectBean");
>        ProjectBean projBean = (ProjectBean)obj;
>
> thanks,
> dean
>
>

-- 
Pierpaolo Follia
Wave S.r.l. - Vai Benaco 24/B, Bedizzole (BS)
Telefono: +39 030 687561
Fax: +39 030 6875690