Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-10529

Add Util function to return succes or error in request

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • Trunk, Upcoming Branch
    • None
    • framework
    • None

    Description

      Currently on base code we have many sequence like this

                      String errMsg = ServiceUtil.getErrorMessage(locaResult);
                      Debug.logError(errMsg, module);
                      request.setAttribute("_ERROR_MESSAGE_", errMsg);
                      return "error";
      

      or

                      String errMsg = UtilProperties.getMessage(resource,
                              "loginevents.change_password_request_error_not_valid_parameters", locale);
                      Debug.logError(errMsg, module);
                      request.setAttribute("_ERROR_MESSAGE_", errMsg);
                      return "error";
      

      I propose to implement some function in WebappUtil like ServiceUtil to return error or success message to the webApp as

      return WebAppUtil.returnError(request, ServiceUtil.getErrorMessage(locaResult), module);
      
      return WebAppUtil.returnError(request, ressource, "loginevents.change_password_request_error_not_valid_parameters", module);
      

      and the function can be write :

      public static String returnError(HttpServletRequest request, String errMsg, String logOriginModule) {
                      if (logOriginModule != null) Debug.logError(errMsg, logOriginModule);
                      request.setAttribute("_ERROR_MESSAGE_", errMsg);
                      return "error";
      }
      

      It's few improvement but it will be delete some duplicated code ^^
      Any opinions ?

      Attachments

        Activity

          People

            nmalin Nicolas Malin
            nmalin Nicolas Malin
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: