Implemented: Define return user message from controller (OFBIZ-12652)
Currently, when you wish return a message to a user after an event request, you need to set it ine the called event.
for a service in java :
ServiceUtil.returnSuccess("Your service is a success")
for a service in groovy :
return success("Your service is a success")
for a Java class :
request.setAttribute("_EVENT_MESSAGE_", "Your service is a success");
If during an integration, you want to use standard service like createProduct, createPartyRelationship, and need a specific message for users, you need to define your own service.
For escape this case and increase the service usability, I propose to implement a new system to override the event return by a definition depending on the buisness context.
For that two improvement :
1. Add new child element to request-map->response on the controller
With given the exact value:
<response name="success" type="request" value="json">
<return-user-message value="Your service is a success"/>
</response>
With a flexible expander:
<response name="success" type="request" value="json">
<return-user-message value="Your service to change is a success"/>
</response>
With a property:
<response name="success" type="request" value="json">
<return-user-message ressource="CommonUiLabels" value="CommonSuccessfullyCreated"/>
</response>
From a context field:
<response name="success" type="request" value="json">
<return-user-message from-field="mySpecificReturnMessage"/>
</response>
2. From the context directly sent from the form
<form name="CallEvent" target="MyEvent" .. >
<field name="_CUSTOM_EVENT_MESSAGE_"> <hidden value="Your service to change is a success"/>
<field name="_CUSTOM_ERROR_MESSAGE_"> <hidden value="Your service failed"/>
Thanks to Florian Motteau for the implementation help
3 files changed