navigating pages in JSF

L

Lew

Pradyut said:
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>
 
L

Lew

Lew said:
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.
 
D

David Segall

Pradyut said:
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.
 
P

Pradyut Bhattacharya

David Segall said:
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
 
L

Lew

Pradyut said:
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?

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.
 
D

David Segall

Pradyut Bhattacharya said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top