Skip to Content
2
Former Member
Mar 18, 2017 at 06:20 PM

Backoffice clone : passing context data to configurableFlowWizard

1016 Views

Hi All,

Hybris version 5.7.13

i have created a clone action button in my custom product editor area. Below is the configuration and code

  1. editorarea action context " action action-id="com.hybris.cockpitng.action.clone"property="currentObject"

  2. definition.xml for action

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
         <action-definition id="com.hybris.cockpitng.action.clone"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/action-definition.xsd">
             <name>Clone Action</name>
             <description>Action providing default implementation of clone operationfrom create operation.</description>
             <author>hybris</author>
             <version>1.0</version>
             <actionClassName>com.web.event.actions.clone.CloneAction</actionClassName>
             <sockets>
                 <input id="currentObject" type="com.web.core.model.EventModel" />
                 <output id="wizardContext" type="java.util.Map" />
             </sockets>
             <inputType>java.lang.Object</inputType>
             <outputType>java.lang.Object</outputType>
             <iconUri>icons/icon_action_event_clone_default.png</iconUri>
             <iconHoverUri>icons/icon_action_event_clone_default.png</iconHoverUri>
             <iconDisabledUri>icons/icon_action_event_clone_disabled.png
             </iconDisabledUri>
         </action-definition>
    
    

3.CUSTOM ACTION PERFORM METHOD

 public ActionResult<Object> perform(ActionContext<Object> ctx) {
           ActionResult<Object> result = null;
             if ((ctx.getData() instanceof EventModel))
             {
                   final EventModel data = (EventModel) ctx.getData();
                    final Map<String, Object> contextMap = new HashMap<>();
                    contextMap.put(ConfigurableFlowContextParameterNames.TYPE_CODE.getName(), "Event");
                    contextMap.put("name", data.getName());
                    contextMap.put("summary", data.getSummary());
                    sendOutput("wizardContext",contextMap);
                    System.out.println(ctx.getParameter("ctx.name"));
                     result = new ActionResult<>(ActionResult.SUCCESS,data);
             }
             else {
               result = new ActionResult<>(ActionResult.ERROR);
             }
                return result;
     }

WIDGET CONNECTION

 <widget-connection sourceWidgetId="STUB_com.hybris.cockpitng.action.clone" outputId="wizardContext" targetWidgetId="configurableFlow" inputId="context"/>

cockpit-config.xml for the context parameters to load

 <wz:prepare id="eventPrepare">
 <wz:initialize property="newEvent" type="ctx.TYPE_CODE" />
 <wz:assign property="newEvent.name" value="ctx.name" />
 <wz:assign property="newEvent.summary" value="ctx.summary" />
 </wz:prepare>

After trying the above method to clone a object and pre fill the context through hashmap to a configurable flow wizard . The values are send through the socket to output but not gettting populated in the wizard. Can any one guide me if i am doing anything wrong in the procedure. ?

Attached the image of the wizard after clicking the action, in fact the TYPE_CODE is set in the contextMap opens the exact wizard belong to the TYPE_CODE except the data.

alt text

Attachments

8102-wiz.jpg (90.6 kB)