With request, you mean HttpServletRequest? In that case, yes you can get it
from a Java class (managed bean, but also a validator, converter, etc., as
long as you are inside a Faces request).

Just call: HttpServletRequest req = (HttpServletRequest)
(FacesContext.getCurrentInstance().getExternalContext().getRequest());

The cast is needed because JSF can also run inside a Portlet container. In
that case, you need to cast to portletrequest.

Hope this solves your problem,

Jan-Kees


2008/11/15 tong123123 <[EMAIL PROTECTED]>

> No, the hello world example have not
> shown how to get a request object in managed bean.
> the code is
>
> public class HelloWorldBacking {
>
>
>    //properties
>    private String name;
>
>    /**
>     * default empty constructor
>     */
>    public HelloWorldBacking(){
>    }
>
>    //-------------------getter & setter
>    public String getName() {
>        return name;
>    }
>    public void setName(String name) {
>        this.name = name;
>    }
>
>    /**
>     * Method that is backed to a submit button of a form.
>     */
>    public String send(){
>        //do real logic
>        return ("success");
>    }
> }
>
> the HelloWorldBacking has not shown how to
> get the request object, is it impossible or
> if possible, how to get the request object
> in HelloWorldBacking bean?
>
>
> --- 2008年11月15日 星期六,Gerhard Petracek <[EMAIL PROTECTED]> 寫道﹕
>
> > 寄件人: Gerhard Petracek <[EMAIL PROTECTED]>
> > 主題: Re: can I get the request object in managed bean?
> > 收件人: "MyFaces Discussion" <[email protected]>,
> [EMAIL PROTECTED]
> > 日期: 2008 11 15 星期六 上午 4:12
> > hello,
> >
> > the hello world example(s) will help you to get a basic
> > idea.
> > a description to generate these examples is available at
> > [1]
> >
> > regards,
> > gerhard
> >
> > [1]
> > http://wiki.apache.org/myfaces/MyFaces_Archetypes_for_Maven
> >
> >
> >
> > 2008/11/14 tong123123 <[EMAIL PROTECTED]>
> >
> > > as captioned, when I submit a jsf form,
> > > where will the requst go to? can I get
> > > the request object in managed bean?
> > > how to get it in managed bean?
> > >
> > >
> > >      為了不斷提升Yahoo!
> > Mail,雅虎香港誠邀你參與意見調查。請前往
> > > http://surveylink.yahoo.com/wix/p5429076.aspx
> > 發表你的意見!
> > >
> >
> >
> >
> > --
> >
> > http://www.irian.at
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
>
>
>      為了不斷提升Yahoo! Mail,雅虎香港誠邀你參與意見調查。請前往
> http://surveylink.yahoo.com/wix/p5429076.aspx 發表你的意見!
>

Reply via email to