You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Jacques Le Roux (JIRA)" <ji...@apache.org> on 2018/08/19 04:52:00 UTC

[jira] [Commented] (OFBIZ-10529) Add Util function to return succes or error in request

    [ https://issues.apache.org/jira/browse/OFBIZ-10529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16585007#comment-16585007 ] 

Jacques Le Roux commented on OFBIZ-10529:
-----------------------------------------

Hi Nicolas,

I see no problems with that, I even like the idea. What for cases with label parameters?

Also there are cases in current code where logError is not used, or another debug level is used. I guess it's not your idea to change them and it should just be used in new code?  Anyway, it does not hinder to use the idea in new code. +1

> Add Util function to return succes or error in request
> ------------------------------------------------------
>
>                 Key: OFBIZ-10529
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-10529
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>    Affects Versions: Trunk
>            Reporter: Nicolas Malin
>            Assignee: Nicolas Malin
>            Priority: Minor
>
> Currently on base code we have many sequence like this
> {code:java}
>                 String errMsg = ServiceUtil.getErrorMessage(locaResult);
>                 Debug.logError(errMsg, module);
>                 request.setAttribute("_ERROR_MESSAGE_", errMsg);
>                 return "error";
> {code}
> or
> {code:java}
>                 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";
> {code}
> I propose to implement some function in WebappUtil like ServiceUtil to return error or success message to the webApp as
> {code:java}
> return WebAppUtil.returnError(request, ServiceUtil.getErrorMessage(locaResult), module);
> {code}
> {code:java}
> return WebAppUtil.returnError(request, ressource, "loginevents.change_password_request_error_not_valid_parameters", module);
> {code}
> and the function can be write :
> {code:java}
> public static String returnError(HttpServletRequest request, String errMsg, String logOriginModule) {
>                 if (logOriginModule != null) Debug.logError(errMsg, logOriginModule);
>                 request.setAttribute("_ERROR_MESSAGE_", errMsg);
>                 return "error";
> }
> {code}
> It's few improvement but it will be delete some duplicated code ^^
>  Any opinions ?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)