Announcement Announcement Module
Collapse
No announcement yet.
Non user entered data Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Non user entered data

    Hey Guys,

    I am pretty new to web flow, so please forgive me if this is a silly question. I have a basic web flow setup with JSPs and model classes. I don't have any form beans or controllers. I use the model class to directly bind with JSP elements so that spring can do all the wiring for me. Once submitted i do validation and other back end calculations on the user submitted data. There is one JSP in which i have a list of links coming from a backend which are shown on the page. I need to capture what link the user clicked on and act accordingly (branch of to a different view state). I am not sure how to achieve this in the web flow way of doing things. Till now now i only had <form:input> tags and submit buttons which took care of user input, but i am not sure how to capture what the user clicked on. Any help is appreciated.

  • #2
    After looking at the examples in the spring web flow zip file, it looks like i need something like what swf-booking-mvc\src\main\webapp\WEB-INF\hotels\search.jsp does in the swf-booking-mvc example. Its using a view controlled by a Spring Controller to handle a user click

    Code:
    <a href="show?id=${hotel.id}">View Hotel</a>
    Somehow this request gets mapped to

    Code:
     @RequestMapping(method = RequestMethod.GET)
        public Hotel show(@RequestParam("id") Long id) {
    	return bookingService.findHotelById(id);
        }
    in src\main\java\org\springframework\webflow\samples\ booking\HotelsController.java

    My question is how does the /show?id gets mapped to the show method in HotelsController and also the show method returns a Hotel object and not a ModelAndView..how does search.jsp gets displayed with the hotel object populated? Any help is appreciated.

    Comment


    • #3
      Ok..looks like ControllerClassNameHandlerMapping is the one which is doing the magic. So i finally figured out that for any dealing with request params, click pairs and anything that doesnt fit into the web flow model you have to fall back to MVC controllers. I ended up writing a custom MulitAction controller with a handler mapped to that request URI. Hopefully this helped someone with the same problem as mine. Question to the web flow team, is this the intended usage of web flow? Do you encourage using plain MVC controllers for things that dont fit into the web flow model?

      Comment

      Working...
      X