I am new to jsf. I would like to know how to pass informatioin between requests. I am able to pass the object in one direction, but never can get it to make a 'round trip'. For instance, I can pass from jsp to my backing bean OR from backing bean to jsp, but For Some reason it never makes it from jsp to backing bean and back to the jsp(and vice versa). In the jsf-jsp im using In the backing bean I use: o = (obj)request.getAttribute("objName"); then I get the facescontext, obtain the request, and put the object back into the request using setAttribute once again. When I check the object in my jsp its null!! Am I missing something? Is there a better way to do this using JSF framework? I should mention, that I dont want to put the Object in the session I only want it to live for a certain amount of time AND I dont want to the responsibility of having to manage removal of these objects from session....anyone have any ideas??
- Posted by: mark rollins
- Posted on: May 10 2007 23:06 EDT
- Re: saving information in a request in jsf by Steven Murray on May 11 2007 08:57 EDT
- saving information in a request in jsf by Ravindranath P on July 01 2010 04:43 EDT
My first question is why are you using
i'm new to JSF so forgive the lack of understanding.... Basically I have certain objects that I want to survive while i'm processing data on a particular JSF page. If I can save these objects between requests, I can avoid trips to the DB. In order to put minimal strain on the application server, I want to avoid storing the object in the session. However, if there's an easy way for me to guarantee that I can clean the objects from the session when I leave the page i'm not opposed to putting the objects in session....any ideas??
Mark, Could you tell me what URL you hit first? It matters as in any MVC, you have to hit the controller first. In JSF, that is the faces servlet related to your application. If you hit the JSP/JSF, without involving the controller, the "round trip" would not work properly. HTH
In order to hold the data from one request to another request you can use the xmlns:a4j="http://richfaces.org/a4j" tag. In your page just use the tag given and the code <a4j:keepAlive beanName="manifestHeaderBean" /> where bean name is the managed bean which you are going to use for data process. Below is the sample code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:f="http://java.sun.com/jsf/core" xmlns:giccs="http://com.crimsonlogic.trade/giccs" xmlns:ui="http://java.sun.com/jsf/facelets">
....Do your logic here
" id="beanLive7" />
Thats it :)