navigating pages in JSF

Discussion in 'Java' started by Pradyut, Aug 30, 2007.

  1. Pradyut

    Pradyut Guest

    Pradyut, Aug 30, 2007
    #1
    1. Advertising

  2. Pradyut

    Lew Guest

    Pradyut wrote:
    > Hi,
    > I m using netbeans IDE 6.0. I want to know how to navigate pages
    > in JSF. I can forward from one page to another using page navigation
    > but want to know how to send and retrieve parameters in JSF pages...


    <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFIntro6.html#wp115538>
    <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFPage10.html#wp119785>

    --
    Lew
     
    Lew, Aug 30, 2007
    #2
    1. Advertising

  3. Pradyut

    Pradyut Guest

    On Aug 31, 1:52 am, Lew <> wrote:
    > Pradyut wrote:
    > > Hi,
    > > I m using netbeans IDE 6.0. I want to know how to navigate pages
    > > in JSF. I can forward from one page to another using page navigation
    > > but want to know how to send and retrieve parameters in JSF pages...

    >
    > <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFIntro6.html#wp115538>
    > <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFPage10.html#wp119785>
    >
    > --
    > Lew


    I can navigate to a different page and can forward to different pages
    depending on the form validations. But i cannot forward the parameters
    like textfield to the forwarded page nor do i know to retrieve the
    values.

    thanks
    Pradyut
    http://pradyut.tk
    India
     
    Pradyut, Aug 30, 2007
    #3
  4. Pradyut

    Lew Guest

    Pradyut wrote:
    > On Aug 31, 1:52 am, Lew <> wrote:
    >> Pradyut wrote:
    >>> Hi,
    >>> I m using netbeans IDE 6.0. I want to know how to navigate pages
    >>> in JSF. I can forward from one page to another using page navigation
    >>> but want to know how to send and retrieve parameters in JSF pages...

    >> <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFIntro6.html#wp115538>
    >> <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFPage10.html#wp119785>


    > I can navigate to a different page and can forward to different pages
    > depending on the form validations. But i cannot forward the parameters
    > like textfield to the forwarded page nor do i know to retrieve the
    > values.


    The managed-bean element in the faces-config.xml can specify that a property
    be initialized from a session value. You can either declare a (small!)
    managed-bean of session scope or explicitly place an attribute in the session
    in your forwarding page's backing bean's action method.

    <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFConfigure3.html#wp1000014>

    --
    Lew
     
    Lew, Aug 30, 2007
    #4
  5. Pradyut

    Lew Guest

    Lew wrote:
    > Pradyut wrote:
    >> On Aug 31, 1:52 am, Lew <> wrote:
    >>> Pradyut wrote:
    >>>> Hi,
    >>>> I m using netbeans IDE 6.0. I want to know how to navigate pages
    >>>> in JSF. I can forward from one page to another using page navigation
    >>>> but want to know how to send and retrieve parameters in JSF pages...
    >>> <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFIntro6.html#wp115538>
    >>> <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFPage10.html#wp119785>

    >
    >> I can navigate to a different page and can forward to different pages
    >> depending on the form validations. But i cannot forward the parameters
    >> like textfield to the forwarded page nor do i know to retrieve the
    >> values.

    >
    > The managed-bean element in the faces-config.xml can specify that a
    > property be initialized from a session value. You can either declare a
    > (small!) managed-bean of session scope or explicitly place an attribute
    > in the session in your forwarding page's backing bean's action method.
    >
    > <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFConfigure3.html#wp1000014>


    It doesn't even have to be session scope. I haven't tried it with JSF yet
    myself, but in my own MVC-cycle servlets in non-JSF projects I just placed
    attributes in the request, which avoids a host of session-related
    complications. I betcha JSF supports that sort of thing, too. Place the
    attribute in the request (not the session) and refer to it in the
    managed-property via the EL with a scoped attribute.

    --
    Lew
     
    Lew, Aug 30, 2007
    #5
  6. Pradyut

    David Segall Guest

    Pradyut <> wrote:

    >Hi,
    > I m using netbeans IDE 6.0. I want to know how to navigate pages
    >in JSF. I can forward from one page to another using page navigation
    >but want to know how to send and retrieve parameters in JSF pages...

    JSF expects the parameters to be properties of a managed bean. If you
    use the Visual Web Pack <http://www.netbeans.org/products/visualweb/>
    to develop your JSF project then it will handle the details of
    managing the managed beans. If you don't use the Visual Web Pack you
    will need to write the beans yourself and write the XML to tell the
    server about them. In either case you will need to do some reading on
    the scope of the beans and how to set and get the variables in them.

    If you must use GET data to send parameters I have a brief note on how
    to retrieve them from a JSF page at
    <http://www.profectus.com.au/ee_getdata.html>. The task is complex if
    you don't use the Visual Web Pack and trivial if you do.
     
    David Segall, Aug 31, 2007
    #6
  7. "David Segall" <> wrote in message
    news:...
    > Pradyut <> wrote:
    >
    >>Hi,
    >> I m using netbeans IDE 6.0. I want to know how to navigate pages
    >>in JSF. I can forward from one page to another using page navigation
    >>but want to know how to send and retrieve parameters in JSF pages...

    > JSF expects the parameters to be properties of a managed bean. If you
    > use the Visual Web Pack <http://www.netbeans.org/products/visualweb/>
    > to develop your JSF project then it will handle the details of
    > managing the managed beans. If you don't use the Visual Web Pack you
    > will need to write the beans yourself and write the XML to tell the
    > server about them. In either case you will need to do some reading on
    > the scope of the beans and how to set and get the variables in them.
    >
    > If you must use GET data to send parameters I have a brief note on how
    > to retrieve them from a JSF page at
    > <http://www.profectus.com.au/ee_getdata.html>. The task is complex if
    > you don't use the Visual Web Pack and trivial if you do.


    I'm still not getting it.....
    I'm using this code to retrive the values.......

    FacesContext fc = FacesContext.getCurrentInstance();
    String id = (String)
    fc.getExternalContext().getRequestParameterMap().get("Page1.textField1");

    Pls some help

    Thanks
    Pradyut
    http://pradyut.tk
    India
     
    Pradyut Bhattacharya, Sep 1, 2007
    #7
  8. Pradyut

    Lew Guest

    Pradyut Bhattacharya wrote:
    > I'm still not getting it.....
    > I'm using this code to retrive the values.......
    >
    > FacesContext fc = FacesContext.getCurrentInstance();
    > String id = (String)
    > fc.getExternalContext().getRequestParameterMap().get("Page1.textField1");
    >
    > Pls [sic] some help


    Did you read the links I suggested?
    > <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFIntro6.html#wp115538>
    > <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFPage10.html#wp119785>
    > <http://java.sun.com/javaee/5/docs/tutorial/doc/JSFConfigure3.html#wp1000014>


    You don't use explicit code like that to retrieve values. You do it by
    binding your "value" attribute to a backing bean property, which bean is
    specified in the faces-config.xml. JSF does the mapping for you.

    Read the part about the JSF life cycle in the tutorial. Study it thoroughly.
    Let us know that you've read the material before you repeat your questions
    again. Then if you have specific questions about the material you can ask
    them based on your reading, which you must do first.

    --
    Lew
     
    Lew, Sep 1, 2007
    #8
  9. Pradyut

    David Segall Guest

    "Pradyut Bhattacharya" <> wrote:

    >
    >"David Segall" <> wrote in message
    >news:...
    >> Pradyut <> wrote:
    >>
    >>>Hi,
    >>> I m using netbeans IDE 6.0. I want to know how to navigate pages
    >>>in JSF. I can forward from one page to another using page navigation
    >>>but want to know how to send and retrieve parameters in JSF pages...

    >> JSF expects the parameters to be properties of a managed bean. If you
    >> use the Visual Web Pack <http://www.netbeans.org/products/visualweb/>
    >> to develop your JSF project then it will handle the details of
    >> managing the managed beans. If you don't use the Visual Web Pack you
    >> will need to write the beans yourself and write the XML to tell the
    >> server about them. In either case you will need to do some reading on
    >> the scope of the beans and how to set and get the variables in them.
    >>
    >> If you must use GET data to send parameters I have a brief note on how
    >> to retrieve them from a JSF page at
    >> <http://www.profectus.com.au/ee_getdata.html>. The task is complex if
    >> you don't use the Visual Web Pack and trivial if you do.

    >
    >I'm still not getting it.....
    >I'm using this code to retrive the values.......
    >
    > FacesContext fc = FacesContext.getCurrentInstance();
    > String id = (String)
    >fc.getExternalContext().getRequestParameterMap().get("Page1.textField1");

    This is definitely wrong but I can't guess what it should be from this
    fragment. JSF expects the data to be passed via a managed bean so if
    you are simply passing data from one JSF page to another you should
    not be using a FacesContext.

    An explanation of managed beans requires an entire chapter in any JSF
    text book and it is not possible to give you some cookbook code in a
    Usenet post.
     
    David Segall, Sep 1, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dudu
    Replies:
    0
    Views:
    381
  2. Sebastian Fey

    JSF debugging / JSF newsgroup

    Sebastian Fey, Apr 7, 2006, in forum: Java
    Replies:
    1
    Views:
    7,634
    Danno
    Apr 7, 2006
  3. BlackIce
    Replies:
    1
    Views:
    17,181
  4. mimoh

    Navigating between pages

    mimoh, Aug 15, 2006, in forum: Java
    Replies:
    0
    Views:
    400
    mimoh
    Aug 15, 2006
  5. Stratum
    Replies:
    2
    Views:
    418
    Stratum
    Jun 25, 2007
Loading...

Share This Page