1

我喜欢像我们在太阳能热索引上使用的向导一样,并且在我的自定义按钮向导没有打开,我的自定义按钮正在删除按钮旁边的项目列表视图中为此,我尝试以下代码,你能帮助我吗我在这里尝试错了

  1. 在action文件夹中创建definition.xml并创建action类,在config.xml中配置相同
  2. 在widget.xml 中的widget 文件夹、控制器类和widget 连接中创建了definition.xml

什么应该是widgetdefinationid?在控制台上发生争执 WARN [hybrisHTTP30] [DefaultActionRenderer] 非法配置!动作类“de.hybris.platform.actions.MyAction”需要“de.hybris...path.myModel”作为输入,但配置为在“java.lang.String”的上下文中使用

定义.xml

<action-definition id="path.actions.MyAction" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/action-definition.xsd">
    <name>MyAction</name>
    <description>MyAction</description>
    <author>Me</author>
    <version>0.1</version>  

    <actionClassName>path.actions.MyAction</actionClassName>

    <inputType>de.hybris.platform.services.model.myModel</inputType>
    <outputType>java.lang.Object</outputType>
    <iconUri>icons/icon_action_search_prices_default.png</iconUri>

    <sockets>
        <output id="typeCode" type="java.lang.String" /> 
    </sockets> 
</action-definition>

MyAction 类

public class MyAction extends AbstractComponentWidgetAdapterAware
        implements CockpitAction<myModel, myModel>
{
    private static final String SOCKET_OUT_CURRENT_PRINCIPAL = "typeCode";

    @Override
    public ActionResult<myModel> perform(final ActionContext<myModel> ctx)
    {

        ActionResult<myModel> result = new ActionResult<>(ActionResult.ERROR);
        if (ctx.getData() != null)
        {

            sendOutput(SOCKET_OUT_CURRENT_PRINCIPAL, ctx.getCode());
            result = new ActionResult<>(ActionResult.SUCCESS);
        }
        return result;
    }
}

配置文件

<context type="testtype" component="listviewactions" merge-by="type">
    <y:actions xmlns:y="http://www.hybris.com/cockpit/config/hybris">
        <y:group qualifier="common">
            <y:action action-id="path.actions.MyAction" property="pageable.typeCode"/>
        </y:group>
    </y:actions>
</context> 

小部件文件夹中的定义.xml

<widget-definition id="abc.searchWidget" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/widget-definition.xsd">
    <name>Search POC</name>
    <description>A widget to</description>
    <defaultTitle></defaultTitle>
    <author>me</author>
    <version>0.1</version>
        <view src="searchPoc.zul"/>
    <keywords>
        <keyword>SearchPocWidget</keyword>
    </keywords>
    <controller class="de.hybris.platform.controller.MySearchController"/>
    <sockets>
        <input id="inputObjectInput" type="java.lang.Object" />
        <output id="refreshUI" type="java.lang.Object" />
    </sockets>
</widget-definition>

小部件.xml

<widget-extension widgetId="hmc2list" >

   <widget id="my-search-widget" widgetDefinitionId="com.hybris.cockpitng.backoffice.referenceadvancedsearchgroup"
    slotId="cockpitWidgetChildrenInvisible" template="true" title="my serach button">
        <widget id="mysearchwidget"
            widgetDefinitionId="abc.searchWidget"
            slotId="children" template="false" title=" widget"
            >
        </widget>
       </widget>
      <setting key="_width" type="String">70%</setting>
        <setting key="_height" type="String">75%</setting>

</widget-extension>
<widget-connection sourceWidgetId="path.actions.MyAction" outputId="typeCode" targetWidgetId="my-search-widget" inputId="activate" />

zul 文件

<widget xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.zkoss.org/2005/zul">
    <style src="${wr}/default.css"/>
    <div>
        <hlayout>
        hi
        </hlayout>
    </div>
</widget>
public class MySearchController extends DefaultWidgetController
{
    private Textbox searchInput;


    @ViewEvent(componentID = "searchBtn", eventName = Events.ON_CLICK)
    public void doSearch() throws InterruptedException
    {
        final List<String> result = search(searchInput.getText());
        Messagebox.show(result.get(0));
    }

    public List<String> search(final String text)
    {
        final List<String> result = new ArrayList<String>();
        result.add(text);
        result.add("Hello");
        result.add("Cockpit NG");


        return result;
    }
}
4

0 回答 0