Discussions

EJB programming & troubleshooting: saving information in a request in jsf

  1. saving information in a request in jsf (4 messages)

    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??
  2. My first question is why are you using
    . The difference between JSP % and JSF # is significant. Second why are you setting the attribute in the request and third since a request by definition never survives the current transaction why would you expect to get it back? Every thing you have done is JSP not JSF. What is it you are trying to do in JSF?
  3. 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??
  4. Re: saving information in a request in jsf[ Go to top ]

    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
  5. 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">
    <ui:composition template="../common/template.xhtml">
    <ui:define name="homeLinkContent">

    <h:form id="createContainer">

    ....Do your logic here

    <a4j:keepAlive beanName="manifestHeaderBean
    " id="beanLive7" />

      </h:form>

     

    Thats it :)