You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2022/07/15 14:00:00 UTC
[jira] [Commented] (OFBIZ-12652) Define return user message from controller or context
[ https://issues.apache.org/jira/browse/OFBIZ-12652?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17567256#comment-17567256 ]
ASF subversion and git services commented on OFBIZ-12652:
---------------------------------------------------------
Commit e12c98ac5b1fcd58a8143707b5a80a333964b7ab in ofbiz-framework's branch refs/heads/trunk from Nicolas Malin
[ https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=e12c98ac5b ]
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
> Define return user message from controller or context
> -----------------------------------------------------
>
> Key: OFBIZ-12652
> URL: https://issues.apache.org/jira/browse/OFBIZ-12652
> Project: OFBiz
> Issue Type: New Feature
> Components: framework/webapp
> Affects Versions: 22.01.01, Upcoming Branch
> Reporter: Nicolas Malin
> Assignee: Nicolas Malin
> Priority: Major
> Labels: event, message, user-experience
> Attachments: OFBIZ-12652.patch
>
>
> 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 :
> {code:java}
> ServiceUtil.returnSuccess("Your service is a success"){code}
>
> for a service in groovy :
> {code:java}
> return success("Your service is a success"){code}
>
> for a Java class :
> {code:java}
> request.setAttribute("_EVENT_MESSAGE_", "Your service is a success");{code}
>
> If during an integration, you want to use standard service like createProduct, createPartyRelationship, and need a specific message for users, you need to define you own service.
> For escape this case and increase the service reusability, I propose to implement a new systeme to override the event return by a definition depending the buisness context.
> For that two improvement :
> 1. Add new child element to reques-map->response on the controller
> * With given the exact value
> {code:java}
> <response name="success" type="request" value="json">
> <return-user-message value="Your service is a success"/>
> </response>{code}
>
> * With a flexible expander
> {code:java}
> <response name="success" type="request" value="json">
> <return-user-message value="Your service to change is a success"/>
> </response>
> {code}
>
> * With a property
> {code:java}
> <response name="success" type="request" value="json">
> <return-user-message ressource="CommonUiLabels" value="CommonSuccessfullyCreated"/>
> </response>
> {code}
> * From a context field
> {code:java}
> <response name="success" type="request" value="json">
> <return-user-message from-field="mySpecificReturnMessage"/>
> </response>
> {code}
> 2. From the context directly sent from the form
> {code:java}
> <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"/>{code}
>
> related thread on dev : [https://lists.apache.org/thread/bv46xndbny6phfxycbmbmxs4t2n7jr28]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)