Results 1 to 2 of 2

Thread: sessionForm usage scenarios?

  1. #1
    Join Date
    Aug 2004
    Location
    Warsaw, Poland
    Posts
    33

    Default sessionForm usage scenarios?

    Hi,

    I found sessionForm flag in AbstractFormController. In documentation it is described as follows: "This allows you e.g. to retrieve an object from the database, let the user edit it, and then persist it again". This is common scenario and i had found it useful in my previous projects using struts. Now i'm trying the same thing with sessionForm. I've two controllers - one controller simple (A) retrieves bean from service layer and puts it in session (and shows view) allowing users to submit form into second controller (B). Since i've marked B controller with sessionForm it gets Command object from session instead of calling formBackingObject(). Everything works just fine - but I found it very inconvinient to hardcode very long session attribute name into A controller. Since B controller by default searches sesion using getFormSessionAttributeName() which uses class name plus command name to find a command instance in session. I cannot override getFormSessionAttributeName() in B controller since it's final. I wonder if there is a simple way to guess session attribute name in A controller or force b controller to find Command objects under simpler name. Or maybe this is an antipattern?

    Artur

  2. #2
    Join Date
    Aug 2004
    Location
    Warsaw, Poland
    Posts
    33

    Default

    Actually it is not an antipattern, rather I didn't understand flow of AbstractFormController and SimpleFormController:). Matt's blog (http://jroller.com/page/raible/20040504) halped me a lot. The trick is I can use the same controller to show form view (for edit) and for form submission (save changes). It is complete different approach I used to work with struts - but I found it *vert* convinient and clever. In struts I was forced to use different actions (one for show form, one for save changes) or use DispatchAction (but struts actions can have only one associated ActionForm - it is inconvinient when You are forced to use entire form only for indication of entity id You are going to edit).

    I think it would be nice to see much more detailed documentation regerding Controllers in spring documentation.

    Artur

Similar Threads

  1. Memory Usage Management:(
    By vw729 in forum Web
    Replies: 4
    Last Post: Nov 7th, 2006, 01:03 PM
  2. sessionForm usage
    By lime in forum Web
    Replies: 1
    Last Post: Aug 4th, 2005, 05:35 PM
  3. Replies: 2
    Last Post: Jul 26th, 2005, 01:52 AM
  4. Replies: 2
    Last Post: Mar 19th, 2005, 10:28 PM
  5. ACL mask usage question
    By moritz in forum Security
    Replies: 1
    Last Post: Feb 11th, 2005, 12:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •