View Poll Results: Do you come from a Struts background?

Voters
23. You may not vote on this poll
  • Yes

    9 39.13%
  • No

    14 60.87%
Results 1 to 6 of 6

Thread: Spring for the Struts Programmer

  1. #1
    Join Date
    Oct 2004
    Location
    South Africa
    Posts
    5

    Default Spring for the Struts Programmer

    Doesn't someone one to write a tutorial - Spring for the Struts Programmer. I keep getting so confused because I want to program the "Struts" way. For example. Say you have 1 form controller (I have been trying to use SimpleFormController) for Product. View, Update Product etc all goes through this one controller. However, it must send you to different views depending on which option is selected... but you can only have one form view, right? So how do you do it??

    Sorry, just getting frustrated as I can't transfer my knowledge from struts to spring appropriately.

    Thanks
    Kim

  2. #2
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default

    SimpleFormController comes with formView and successView 'out of the box'. But you can add more to your controller, e.g.
    Code:
    public class MyController extends SimpleFormController {
        private String viewOne;
        private String viewTwo;
    
        /* add getters & setters */
    
         public ModelAndView onSubmit( . . .) {
         . . .
         }
    }
    Set the values in your config xml just as you would for formView & successView, and code the logic in your onSubmit to route to the appropriate view. That's to give you different 'success' views (the most common requirement, at least in my experience).
    If you want different form views, you can override showForm() (I believe - i'ts not something I've ever done).

    Hope this helps
    Chris Harris
    Carlisle, UK

  3. #3
    Join Date
    Aug 2004
    Location
    Denver
    Posts
    249

    Default

    I hate to market my book on these forums, but it sounds like Spring Live might be a good book for you. In Chapter 2 (which is available for free), you develop a Struts+Spring+Hibernate application. Then in Chapter 4, that application is refactored to replace Struts with Spring MVC. I tried to write these two chapters from a Struts Developer perspective since I figured that would be a large audience to target.

  4. #4
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Don't worry Matt--it's perfectly legitimate, I believe your book will help with such questions!
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  5. #5
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    Might want to check the link above thought. I tried clicking on it and got an error about the content not starting with something like %PDF, so I guess it's not a valid PDF file...
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  6. #6
    Join Date
    Aug 2004
    Location
    Boston MA
    Posts
    27

    Default

    Colin

    I had the same problem when I tried to view the PDF through FireFox. When I saved the file, then opened it in Acrobat, it worked.


    Keller

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Spring managed Struts Actions
    By drc in forum Web
    Replies: 2
    Last Post: Jul 14th, 2005, 10:46 AM
  3. migrating Struts to Spring (long-winded)
    By ocampesato in forum Web
    Replies: 2
    Last Post: May 6th, 2005, 11:17 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Testing troubles with Struts / Spring
    By anthonyb in forum Web
    Replies: 4
    Last Post: Feb 10th, 2005, 03:44 PM

Posting Permissions

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