You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Nicolas Malin <ni...@nereide.fr> on 2022/06/13 13:45:40 UTC

Use specific message from the business context

Hello,

I wish to expose a thought about the event message returned to an end user.

When you write a screen for edition and wish to inform your end user,
you send your success or error message directly on the request from the
event.

    *****
    <request-map uri="updatePerson">...
        <event type="service" invoke="updatePerson"/>
        <response name="success" type="view-last"/>...
    </request-map>

   PartyServices.java :
        result.put(ModelService.SUCCESS_MESSAGE,
            UtilProperties.getMessage(RES_ERROR,
"person.update.success", locale));

    *****

During an implementation on a custom site, if you want to use a specific
message after updating a person, you need to create a specific service :

    *****
     <request-map uri="updatePersonFromHere">...
        <event type="service" invoke="updatePersonFromHere"/>
        <response name="success" type="view-last"/>...
     </request-map>
   
    CustomServices.java :
        run service: "updatePerson", with: parameters
        return success("my specific message")
    *****
       
If you have an other case, an other service

An other vision would be to set the message around the event directly on
the request.

    *****
     <request-map uri="updatePersonFromHere">...
        <event type="service" invoke="updatePerson"/>
        <response name="success" type="view-last">
            <user-message ressource="CustomUiLabels"
value="SuccessUpdatePersonFromHere"/>
        </response>...
     </request-map>

    *****

Why: when you write your custom code, in many case (in any case for me)
you call a generic service or other event type but wish return a exact
message not from the operation in the service but more from where the
call is submitted.

Other idea to improve more we can imagine setting the message direclty
from the form

    *****
   <form type="single" target="updatePerson">
      <field name="_CUSTOM_EVENT_MESSAGE_" ><hidden value="Thanks for
the update ${partyId}"/></field>
      <field name="_CUSTOM_ERROR_MESSAGE_" ><hidden value="ARRRG update
failed"/></field>
    ...
    *****   

What is your feeling about that ?

Thanks
Nicolas
-- 
logoNrd <https://nereide.fr/>
	Nicolas Malin
The apache way <http://theapacheway.com/> : *Charity* Apache’s mission
is providing software for the public good.
information@nereide.fr
8 rue des Déportés 37000 TOURS, 02 47 50 30 54

Apache OFBiz <http://ofbiz.apache.org/>|The Apache Way
<http://theapacheway.com/>|réseau LE <http://www.libre-entreprise.org/>

Re: Use specific message from the business context

Posted by Nicolas Malin <ni...@nereide.fr>.
Sure Jacques,

My problem isn't to improve or not it but more if the way that I suggest
can be confronted with the reasoning of my peers :D

I opened the issue OFBIZ-12652[1] with the code extracted from the
custom site.

Cheers,
Nicolas

[1] https://issues.apache.org/jira/browse/OFBIZ-12652

On 16/06/2022 10:58, Jacques Le Roux wrote:
> Hi Nicolas,
>
> I'd say, that as long as it does not break what exists, so are just
> improvements, I see no reasons to not add them.
>
> My 2 cts
>
> Jacques
>
> Le 15/06/2022 à 11:24, Nicolas Malin a écrit :
>> Yes sure Jacques,
>>
>> I already implement both but before suggest it as code, I preferred to
>> expose the logic to be sure that we going to on the good way :)
>>
>> If you confirm that this idea isn't wrong (break pattern or something
>> like that) I will open the issue to load the code
>>
>> Cheers,
>> Nicolas
>>
>> On 14/06/2022 17:21, Jacques Le Roux wrote:
>>> Hi Pierre, Nicolas,
>>>
>>> I like the idea of the right and wrong messages from form. Could we
>>> not have both (request-map and form) to use them accordingly to our
>>> (custom for instance) needs?
>>>
>>> Jacques
>>>
>>> Le 14/06/2022 à 09:12, Pierre Gaudin a écrit :
>>>> Hi Nicolas,
>>>>
>>>> The solution by putting the message directly in the request-map
>>>> response seems to me a good idea. This avoids having to create a
>>>> service just to overload the return message.
>>>>
>>>> I think the idea of putting the message directly in the screen is
>>>> less interesting because the same screen can be used in different
>>>> contexts.
>>>>
>>>> Pierre
>>>>
>>>> Le 13/06/2022 à 15:45, Nicolas Malin a écrit :
>>>>> Hello,
>>>>>
>>>>> I wish to expose a thought about the event message returned to an
>>>>> end user.
>>>>>
>>>>> When you write a screen for edition and wish to inform your end user,
>>>>> you send your success or error message directly on the request
>>>>> from the
>>>>> event.
>>>>>
>>>>>       *****
>>>>>       <request-map uri="updatePerson">...
>>>>>           <event type="service" invoke="updatePerson"/>
>>>>>           <response name="success" type="view-last"/>...
>>>>>       </request-map>
>>>>>
>>>>>      PartyServices.java :
>>>>>           result.put(ModelService.SUCCESS_MESSAGE,
>>>>>               UtilProperties.getMessage(RES_ERROR,
>>>>> "person.update.success", locale));
>>>>>
>>>>>       *****
>>>>>
>>>>> During an implementation on a custom site, if you want to use a
>>>>> specific
>>>>> message after updating a person, you need to create a specific
>>>>> service :
>>>>>
>>>>>       *****
>>>>>        <request-map uri="updatePersonFromHere">...
>>>>>           <event type="service" invoke="updatePersonFromHere"/>
>>>>>           <response name="success" type="view-last"/>...
>>>>>        </request-map>
>>>>>           CustomServices.java :
>>>>>           run service: "updatePerson", with: parameters
>>>>>           return success("my specific message")
>>>>>       *****
>>>>>          If you have an other case, an other service
>>>>>
>>>>> An other vision would be to set the message around the event
>>>>> directly on
>>>>> the request.
>>>>>
>>>>>       *****
>>>>>        <request-map uri="updatePersonFromHere">...
>>>>>           <event type="service" invoke="updatePerson"/>
>>>>>           <response name="success" type="view-last">
>>>>>               <user-message ressource="CustomUiLabels"
>>>>> value="SuccessUpdatePersonFromHere"/>
>>>>>           </response>...
>>>>>        </request-map>
>>>>>
>>>>>       *****
>>>>>
>>>>> Why: when you write your custom code, in many case (in any case
>>>>> for me)
>>>>> you call a generic service or other event type but wish return a
>>>>> exact
>>>>> message not from the operation in the service but more from where the
>>>>> call is submitted.
>>>>>
>>>>> Other idea to improve more we can imagine setting the message
>>>>> direclty
>>>>> from the form
>>>>>
>>>>>       *****
>>>>>      <form type="single" target="updatePerson">
>>>>>         <field name="_CUSTOM_EVENT_MESSAGE_" ><hidden
>>>>> value="Thanks for
>>>>> the update ${partyId}"/></field>
>>>>>         <field name="_CUSTOM_ERROR_MESSAGE_" ><hidden value="ARRRG
>>>>> update
>>>>> failed"/></field>
>>>>>       ...
>>>>>       *****
>>>>>
>>>>> What is your feeling about that ?
>>>>>
>>>>> Thanks
>>>>> Nicolas
>>>>


Re: Use specific message from the business context

Posted by Jacques Le Roux <ja...@les7arts.com>.
Hi Nicolas,

I'd say, that as long as it does not break what exists, so are just improvements, I see no reasons to not add them.

My 2 cts

Jacques

Le 15/06/2022 à 11:24, Nicolas Malin a écrit :
> Yes sure Jacques,
>
> I already implement both but before suggest it as code, I preferred to
> expose the logic to be sure that we going to on the good way :)
>
> If you confirm that this idea isn't wrong (break pattern or something
> like that) I will open the issue to load the code
>
> Cheers,
> Nicolas
>
> On 14/06/2022 17:21, Jacques Le Roux wrote:
>> Hi Pierre, Nicolas,
>>
>> I like the idea of the right and wrong messages from form. Could we
>> not have both (request-map and form) to use them accordingly to our
>> (custom for instance) needs?
>>
>> Jacques
>>
>> Le 14/06/2022 à 09:12, Pierre Gaudin a écrit :
>>> Hi Nicolas,
>>>
>>> The solution by putting the message directly in the request-map
>>> response seems to me a good idea. This avoids having to create a
>>> service just to overload the return message.
>>>
>>> I think the idea of putting the message directly in the screen is
>>> less interesting because the same screen can be used in different
>>> contexts.
>>>
>>> Pierre
>>>
>>> Le 13/06/2022 à 15:45, Nicolas Malin a écrit :
>>>> Hello,
>>>>
>>>> I wish to expose a thought about the event message returned to an
>>>> end user.
>>>>
>>>> When you write a screen for edition and wish to inform your end user,
>>>> you send your success or error message directly on the request from the
>>>> event.
>>>>
>>>>       *****
>>>>       <request-map uri="updatePerson">...
>>>>           <event type="service" invoke="updatePerson"/>
>>>>           <response name="success" type="view-last"/>...
>>>>       </request-map>
>>>>
>>>>      PartyServices.java :
>>>>           result.put(ModelService.SUCCESS_MESSAGE,
>>>>               UtilProperties.getMessage(RES_ERROR,
>>>> "person.update.success", locale));
>>>>
>>>>       *****
>>>>
>>>> During an implementation on a custom site, if you want to use a
>>>> specific
>>>> message after updating a person, you need to create a specific
>>>> service :
>>>>
>>>>       *****
>>>>        <request-map uri="updatePersonFromHere">...
>>>>           <event type="service" invoke="updatePersonFromHere"/>
>>>>           <response name="success" type="view-last"/>...
>>>>        </request-map>
>>>>           CustomServices.java :
>>>>           run service: "updatePerson", with: parameters
>>>>           return success("my specific message")
>>>>       *****
>>>>          If you have an other case, an other service
>>>>
>>>> An other vision would be to set the message around the event
>>>> directly on
>>>> the request.
>>>>
>>>>       *****
>>>>        <request-map uri="updatePersonFromHere">...
>>>>           <event type="service" invoke="updatePerson"/>
>>>>           <response name="success" type="view-last">
>>>>               <user-message ressource="CustomUiLabels"
>>>> value="SuccessUpdatePersonFromHere"/>
>>>>           </response>...
>>>>        </request-map>
>>>>
>>>>       *****
>>>>
>>>> Why: when you write your custom code, in many case (in any case for me)
>>>> you call a generic service or other event type but wish return a exact
>>>> message not from the operation in the service but more from where the
>>>> call is submitted.
>>>>
>>>> Other idea to improve more we can imagine setting the message direclty
>>>> from the form
>>>>
>>>>       *****
>>>>      <form type="single" target="updatePerson">
>>>>         <field name="_CUSTOM_EVENT_MESSAGE_" ><hidden value="Thanks for
>>>> the update ${partyId}"/></field>
>>>>         <field name="_CUSTOM_ERROR_MESSAGE_" ><hidden value="ARRRG
>>>> update
>>>> failed"/></field>
>>>>       ...
>>>>       *****
>>>>
>>>> What is your feeling about that ?
>>>>
>>>> Thanks
>>>> Nicolas
>>>

Re: Use specific message from the business context

Posted by Nicolas Malin <ni...@nereide.fr>.
Yes sure Jacques,

I already implement both but before suggest it as code, I preferred to
expose the logic to be sure that we going to on the good way :)

If you confirm that this idea isn't wrong (break pattern or something
like that) I will open the issue to load the code

Cheers,
Nicolas

On 14/06/2022 17:21, Jacques Le Roux wrote:
> Hi Pierre, Nicolas,
>
> I like the idea of the right and wrong messages from form. Could we
> not have both (request-map and form) to use them accordingly to our
> (custom for instance) needs?
>
> Jacques
>
> Le 14/06/2022 à 09:12, Pierre Gaudin a écrit :
>> Hi Nicolas,
>>
>> The solution by putting the message directly in the request-map
>> response seems to me a good idea. This avoids having to create a
>> service just to overload the return message.
>>
>> I think the idea of putting the message directly in the screen is
>> less interesting because the same screen can be used in different
>> contexts.
>>
>> Pierre
>>
>> Le 13/06/2022 à 15:45, Nicolas Malin a écrit :
>>> Hello,
>>>
>>> I wish to expose a thought about the event message returned to an
>>> end user.
>>>
>>> When you write a screen for edition and wish to inform your end user,
>>> you send your success or error message directly on the request from the
>>> event.
>>>
>>>      *****
>>>      <request-map uri="updatePerson">...
>>>          <event type="service" invoke="updatePerson"/>
>>>          <response name="success" type="view-last"/>...
>>>      </request-map>
>>>
>>>     PartyServices.java :
>>>          result.put(ModelService.SUCCESS_MESSAGE,
>>>              UtilProperties.getMessage(RES_ERROR,
>>> "person.update.success", locale));
>>>
>>>      *****
>>>
>>> During an implementation on a custom site, if you want to use a
>>> specific
>>> message after updating a person, you need to create a specific
>>> service :
>>>
>>>      *****
>>>       <request-map uri="updatePersonFromHere">...
>>>          <event type="service" invoke="updatePersonFromHere"/>
>>>          <response name="success" type="view-last"/>...
>>>       </request-map>
>>>          CustomServices.java :
>>>          run service: "updatePerson", with: parameters
>>>          return success("my specific message")
>>>      *****
>>>         If you have an other case, an other service
>>>
>>> An other vision would be to set the message around the event
>>> directly on
>>> the request.
>>>
>>>      *****
>>>       <request-map uri="updatePersonFromHere">...
>>>          <event type="service" invoke="updatePerson"/>
>>>          <response name="success" type="view-last">
>>>              <user-message ressource="CustomUiLabels"
>>> value="SuccessUpdatePersonFromHere"/>
>>>          </response>...
>>>       </request-map>
>>>
>>>      *****
>>>
>>> Why: when you write your custom code, in many case (in any case for me)
>>> you call a generic service or other event type but wish return a exact
>>> message not from the operation in the service but more from where the
>>> call is submitted.
>>>
>>> Other idea to improve more we can imagine setting the message direclty
>>> from the form
>>>
>>>      *****
>>>     <form type="single" target="updatePerson">
>>>        <field name="_CUSTOM_EVENT_MESSAGE_" ><hidden value="Thanks for
>>> the update ${partyId}"/></field>
>>>        <field name="_CUSTOM_ERROR_MESSAGE_" ><hidden value="ARRRG
>>> update
>>> failed"/></field>
>>>      ...
>>>      *****
>>>
>>> What is your feeling about that ?
>>>
>>> Thanks
>>> Nicolas
>>
>>


Re: Use specific message from the business context

Posted by Jacques Le Roux <ja...@les7arts.com>.
Hi Pierre, Nicolas,

I like the idea of the right and wrong messages from form. Could we not have both (request-map and form) to use them accordingly to our (custom for 
instance) needs?

Jacques

Le 14/06/2022 à 09:12, Pierre Gaudin a écrit :
> Hi Nicolas,
>
> The solution by putting the message directly in the request-map response seems to me a good idea. This avoids having to create a service just to 
> overload the return message.
>
> I think the idea of putting the message directly in the screen is less interesting because the same screen can be used in different contexts.
>
> Pierre
>
> Le 13/06/2022 à 15:45, Nicolas Malin a écrit :
>> Hello,
>>
>> I wish to expose a thought about the event message returned to an end user.
>>
>> When you write a screen for edition and wish to inform your end user,
>> you send your success or error message directly on the request from the
>> event.
>>
>>      *****
>>      <request-map uri="updatePerson">...
>>          <event type="service" invoke="updatePerson"/>
>>          <response name="success" type="view-last"/>...
>>      </request-map>
>>
>>     PartyServices.java :
>>          result.put(ModelService.SUCCESS_MESSAGE,
>>              UtilProperties.getMessage(RES_ERROR,
>> "person.update.success", locale));
>>
>>      *****
>>
>> During an implementation on a custom site, if you want to use a specific
>> message after updating a person, you need to create a specific service :
>>
>>      *****
>>       <request-map uri="updatePersonFromHere">...
>>          <event type="service" invoke="updatePersonFromHere"/>
>>          <response name="success" type="view-last"/>...
>>       </request-map>
>>          CustomServices.java :
>>          run service: "updatePerson", with: parameters
>>          return success("my specific message")
>>      *****
>>         If you have an other case, an other service
>>
>> An other vision would be to set the message around the event directly on
>> the request.
>>
>>      *****
>>       <request-map uri="updatePersonFromHere">...
>>          <event type="service" invoke="updatePerson"/>
>>          <response name="success" type="view-last">
>>              <user-message ressource="CustomUiLabels"
>> value="SuccessUpdatePersonFromHere"/>
>>          </response>...
>>       </request-map>
>>
>>      *****
>>
>> Why: when you write your custom code, in many case (in any case for me)
>> you call a generic service or other event type but wish return a exact
>> message not from the operation in the service but more from where the
>> call is submitted.
>>
>> Other idea to improve more we can imagine setting the message direclty
>> from the form
>>
>>      *****
>>     <form type="single" target="updatePerson">
>>        <field name="_CUSTOM_EVENT_MESSAGE_" ><hidden value="Thanks for
>> the update ${partyId}"/></field>
>>        <field name="_CUSTOM_ERROR_MESSAGE_" ><hidden value="ARRRG update
>> failed"/></field>
>>      ...
>>      *****
>>
>> What is your feeling about that ?
>>
>> Thanks
>> Nicolas
>
>

Re: Use specific message from the business context

Posted by Pierre Gaudin <pi...@cheznous.bzh>.
Hi Nicolas,

The solution by putting the message directly in the request-map response 
seems to me a good idea. This avoids having to create a service just to 
overload the return message.

I think the idea of putting the message directly in the screen is less 
interesting because the same screen can be used in different contexts.

Pierre

Le 13/06/2022 à 15:45, Nicolas Malin a écrit :
> Hello,
>
> I wish to expose a thought about the event message returned to an end user.
>
> When you write a screen for edition and wish to inform your end user,
> you send your success or error message directly on the request from the
> event.
>
>      *****
>      <request-map uri="updatePerson">...
>          <event type="service" invoke="updatePerson"/>
>          <response name="success" type="view-last"/>...
>      </request-map>
>
>     PartyServices.java :
>          result.put(ModelService.SUCCESS_MESSAGE,
>              UtilProperties.getMessage(RES_ERROR,
> "person.update.success", locale));
>
>      *****
>
> During an implementation on a custom site, if you want to use a specific
> message after updating a person, you need to create a specific service :
>
>      *****
>       <request-map uri="updatePersonFromHere">...
>          <event type="service" invoke="updatePersonFromHere"/>
>          <response name="success" type="view-last"/>...
>       </request-map>
>     
>      CustomServices.java :
>          run service: "updatePerson", with: parameters
>          return success("my specific message")
>      *****
>         
> If you have an other case, an other service
>
> An other vision would be to set the message around the event directly on
> the request.
>
>      *****
>       <request-map uri="updatePersonFromHere">...
>          <event type="service" invoke="updatePerson"/>
>          <response name="success" type="view-last">
>              <user-message ressource="CustomUiLabels"
> value="SuccessUpdatePersonFromHere"/>
>          </response>...
>       </request-map>
>
>      *****
>
> Why: when you write your custom code, in many case (in any case for me)
> you call a generic service or other event type but wish return a exact
> message not from the operation in the service but more from where the
> call is submitted.
>
> Other idea to improve more we can imagine setting the message direclty
> from the form
>
>      *****
>     <form type="single" target="updatePerson">
>        <field name="_CUSTOM_EVENT_MESSAGE_" ><hidden value="Thanks for
> the update ${partyId}"/></field>
>        <field name="_CUSTOM_ERROR_MESSAGE_" ><hidden value="ARRRG update
> failed"/></field>
>      ...
>      *****
>
> What is your feeling about that ?
>
> Thanks
> Nicolas