Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-12652

Define return user message from controller or context

    XMLWordPrintableJSON

Details

    Description

      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 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
             <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"/>

       

      related thread on dev : https://lists.apache.org/thread/bv46xndbny6phfxycbmbmxs4t2n7jr28

      Attachments

        1. OFBIZ-12652.patch
          10 kB
          Nicolas Malin

        Activity

          People

            nmalin Nicolas Malin
            nmalin Nicolas Malin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: