Mr.Tr33
Mr.Tr33

Reputation: 868

Hybris HMC: adding a button to ToolBarChip / Editor window next to the save button

I'm working with Hybris 5.6 and I'm trying to add a button in the editor area right next to the save/reload/delete buttons.

How can I add a button to the ToolBarChip like in the example below?

enter image description here

Upvotes: 2

Views: 856

Answers (1)

Mouad EL Fakir
Mouad EL Fakir

Reputation: 3759

It's quite possible to add a new action (label) to the toolbar of HMC, however it's not so recommended as it may result some issues while the migration.

  1. First, add the following snippet to your **/hmc.xml :
<type name="AbstractOrder" mode="append">

  <organizer mode="append" > 
     <editor>
        <tab name="payment_and_delivery" position="2" mode="append">

           <section name="deliveryadministration" mode="append" >
              <table>
                 <tr>
                    <td width="16px">
                    </td>
                    <td>
                       <!-- here is the interesting part -->
                       <action type="item"
                               classname="com.foo.bar.MyNewAction" 
                               name="action.my_new_action"
                               toolbaricon="my_new_action"
                               icon="images/icons/my_new_action_icon.gif"
                               autosave="true"
                               showtoolbarlabel="true"
                               hidebutton="true"
                             />
                    </td>

                 </tr>
              </table>
           </section>

        </tab>
     </editor>
  </organizer>

</type>
  1. Then, define the new action to be performed when the new label is clicked :

    Add a new class called MyNewAction.java that extends from ItemAction and implement the method ActionResult perform(ActionEvent event) :
public MyNewAction extends ItemAction {

    @Override
    public ActionResult perform(ActionEvent actionEvent) throws JaloBusinessException {

        //what the new action should do here ...

    }
}

Note : you could override other interesting methods to be triggers while the action is possessing like : boolean needConfirmation() or String getConfirmationMessage() ...

The result would be like this :

enter image description here

Upvotes: 3

Related Questions