Announcement Announcement Module
Collapse
No announcement yet.
Flash messages and database connections Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment


        • #5
          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!

          Comment

          Working...
          X