You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by mfaine <mf...@knology.net> on 2005/07/08 16:32:16 UTC

Request Parameters are not set by managed bean facility

I'm trying to use the managed bean facility to set fields in my beans from
values passed in a certain scope.  I'm having trouble setting the value for
a field if I use request scope.

In my faces.config I have a bean that is request scope.  If I set the value
of of the managed property "name" to #{param.name} it does not get set in
the bean. 

However, if I use something like:

this.name = (String)
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("form1:name");

in the init method of the bean, this works.

It is very frustrating as I would like to do it using the managed bean facility.

Thanks,
-Mark

    

Re: Request Parameters are not set by managed bean facility

Posted by Mike Kienenberger <mk...@gmail.com>.
[Maybe "param" is an advanced feature of JSF that I don't know about,
and if so, ignore the following.]

Why would this work as you described?

"param" would need to be a managed bean.
You'd have to create a getName() method on this bean that executes

return
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("form1:name");

in order for your expression to work.

That said, I think you could create your own
javax.faces.el.VariableResolver that could do this for you
automatically, if I understand the VariableResolver concept.  Once you
did that, then param.name could be handled as you expect it to work. 
Sounds like it might be a useful extension for myfaces.

-Mike

On 8 Jul 2005 14:32:16 -0000, mfaine <mf...@knology.net> wrote:
> I'm trying to use the managed bean facility to set fields in my beans from
> values passed in a certain scope.  I'm having trouble setting the value for
> a field if I use request scope.
> 
> In my faces.config I have a bean that is request scope.  If I set the value
> of of the managed property "name" to #{param.name} it does not get set in
> the bean.
> 
> However, if I use something like:
> 
> this.name = (String)
> FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("form1:name");
> 
> in the init method of the bean, this works.
> 
> It is very frustrating as I would like to do it using the managed bean facility.
> 
> Thanks,
> -Mark
> 
> 
>