Hybris HMC:在保存按钮旁边向 ToolBarChip/Editor window 添加一个按钮

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

我正在使用 Hybris 5.6,我正在尝试在 save/reload/delete 按钮旁边的编辑器区域中添加一个按钮。

如何向 ToolBarChip 添加按钮,如下例所示?

在 HMC 的工具栏中添加一个新的操作(标签)是很有可能的,但是不推荐这样做,因为它可能会在迁移时导致一些问题

  1. 首先,将以下代码段添加到您的 **/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. 然后,定义单击新标签时要执行的新操作:

    添加一个名为 MyNewAction.java 的新 class,它扩展自 ItemAction 并实现方法 ActionResult perform(ActionEvent event) :
public MyNewAction extends ItemAction {

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

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

    }
}

注意 :您可以覆盖其他有趣的方法以在操作拥有时触发,例如:boolean needConfirmation()String getConfirmationMessage() ...

结果会是这样的: