Вопрос

I often write something like:



    def myAction{ MyActionCommand cmd ->
       if( cmd.hasErrors() ){
          return render(status:HttpServletResponse.SC_BAD_REQUEST );
       }else{
          // actual action logic
       }


So, I'd like to extract that common pattern into some reusable location. Filter looks like good candidate, but I can't find the way to get command object from the filter. Tryed something like this (in filters closure):



    formValidation( controller:'*', action:'*' ){
       before = { cmd ->
          if( cmd.hasErrors() ){
              response.sendError( HttpServletResponse.SC_BAD_REQUEST );
              return false;
          }else{
              return true;
          }
       }
    }


Intersted in grails 1.3.7 compatible solution. Is it possible at all?

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top