Nicolas Malin created OFBIZ-10529:
-------------------------------------
Summary: 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
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)