Results 1 to 5 of 5

Thread: Flash messages and database connections

  1. #1
    Join Date
    Jun 2009
    Location
    Porto Alegre, Brazil
    Posts
    5

    Default Flash messages and database connections

    Hi everyone

    Is Roo planning to provide flash messages that supports redirect (like Rails and Grails) in roo applications? and what about different databases' connections (like dev, test, prod) ?

    I created some spring-mvc and maven2 that use profiles + file filters (of maven) to manager databases connections. Maybe I can turn it a roo add-ons, what do you think?

    And about flash messages, I don't seen any way to make it whitout a roo spring-mvc extension, am I right?

    cheers,
    Max

  2. #2
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    Hi Max,

    Thanks for your interest in Roo!

    Roo (or actually Spring MVC) has a comprehensive tag library which allows for internationalization, message properties and form error handling. Form error handling, for example is done by using the <form:errors tag. As far as I understand it these tags provide pretty much the same functionality as Grails flash messages. Please correct me if I understand something wrong here.

    As for the support for different database environments, this could well be supported by a Roo add-on as suggested by you. Please feel free to open an 'improvement' Jira ticket for this feature and elaborate on your ideas so we can work together. If you already have this implemented we would be happy to take a look and help you further to develop this add-on.

    Regards,
    Stefan

  3. #3
    Join Date
    Jun 2009
    Location
    Porto Alegre, Brazil
    Posts
    5

    Default

    Hi,
    I know spring tags as well but they aren't the same of flash pattern in Rails (or Grails).

    take look this controller generated by Roo:

    Code:
    @RequestMapping(value = "/system/{id}", method = RequestMethod.DELETE)
    public String delete(@PathVariable("id") Long id) {
      if (id == null) 
          throw new IllegalArgumentException("An Identifier is required");        
     
      findSystem(id).remove();        
      return "redirect:/system";
    }

    So, how I could redirect and send a message to client like "System was deleted!" ?

    I Rails we have "flash" :P

    from rails docs:

    4.2 The Flash

    The flash is a special part of the session which is cleared with each request. This means that values stored there will only be available in the next request, which is useful for storing error messages etc. It is accessed in much the same way as the session, like a hash. Let’s use the act of logging out as an example. The controller can send a message which will be displayed to the user on the next request:

    Code:
    class LoginsController < ApplicationController 
      def destroy 
        session[:current_user_id] = nil 
        flash[:notice] = "You have successfully logged out" 
        redirect_to root_url 
      end 
    end

  4. #4
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    Max,

    Now I understand what you mean. Thanks for the example. I have thought about this in the past as well and actually Spring Web Flow has already a flash scope available.

    In Spring MVC you would basically have to resort to writing your own AnnotationMethodHandlerAdapter extension to achieve this. Here is a sample which shows this: http://impalablog.blogspot.com/2009/...nnotation.html

    This is not something that Roo should provide as Roo we have currently no intentions to have Roo dependencies at runtime. We might review this in future though.

    So the best place for a feature request like this would be Spring MVC not Roo...

    Cheers,
    Stefan

  5. #5
    Join Date
    Jun 2009
    Posts
    10

    Default

    There is a Jira issue open for the lack of flash support.

    http://jira.springframework.org/browse/MOD-458

    Vote for it if you think it should be included in Spring MVC, I know I do!

Posting Permissions

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