Me again,

I just had some kind of breakthrough... I think.

Because my .jsp form was specifying the name and type of the form, it wasn't picking 
up on the scope.  If I add scope into the form declaration, I'm ok.  Also if I take 
the name and type out of form I'm ok (but that was causing a problem at some point, so 
I'll have to do more testing to remember what the problem was).

The only glitch is when validation fails, since my drop-downs come back empty.  So I'm 
thinking that I can get around this, but it'll mean extra database calls and be a 
performance problem that way instead of just hogging the session memory.  I guess this 
is why I was told this stuff had to be in the session... it all makes sense now.

Back to the drawing board.

Janice
  ----- Original Message ----- 
  From: Janice 
  To: [EMAIL PROTECTED] 
  Sent: Tuesday, February 24, 2004 2:03 PM
  Subject: need help converting from session to request scope


  Thanks for the responses, Paul and Hubert!

  (I wanted to send this off sooner, but my boss called and wouldn't let me
  off the phone for an hour!  The joy of telecommuting...)

  In response to Paul: I would like to start storing things in the request so
  that I don't have to worry about cleaning up all the many objects I'm
  putting in the session.  I was doing some reading this morning that implied
  that the only reason to store form beans in the session is if I was doing
  multi-paged forms.  I am not doing that in many places, so I would rather
  narrow the scope and not worry about taking up too much memory.  If there
  aren't any performance problems, I could happily leave it alone.

  And I would like to ask why I can't store my lists in the form bean if I'm
  going to request scope?  What I'm doing in most cases is setting up the form
  bean with the lists for drop-downs (if any), and if I'm editing a widget, I
  populate the form with the last saved values.  Then the user submits, I do
  an insert, update or delete and everyone's happy.

  In response to Hubert: I'm using DispatchActions, so the action mapping
  where I set up the scope=request is the same action mapping that does both
  ActionA (showForm) and ActionB (submitForm).  I also did a little test:
  <--- snip --->

        if ( "request".equals(mapping.getScope()) ) {
          log.info("did request scope");
          request.setAttribute(mapping.getAttribute(), form);
        } else {
          log.info("did session scope");
          HttpSession session = request.getSession();
          session.setAttribute(mapping.getAttribute(), form);
        }
  </--- snip --->
  And right before the .jsp bombs my log shows I'm doing request scope.  So
  why can't my .jsp find the stuff in my form?

  After reading Hubert's second email: Sorry, but could you clarify:
  "To use request scope, you can either:
  1) Leave your Strings/ArrayLists in session scope
  2) Put them in application scope
  3) Put them in request scope, then change your ActionB mapping to use
  ActionA
  as input.  You'll need to make sure you don't reset FormA's values in
  ActionA
  when it's for a redisplay."

  Obviously I'm missing something big here.  Is the following thinking flawed:
  "I can pass a formBean from ActionA via request to the .jsp to use and then
  when the user submits I will get a new formBean back via request"?

  Thanks again for your help,
  Janice

Reply via email to