我正在HYBRIS的后台创建一个小部件。
生成扩展程序trainingbackoffice
后,我将其添加到localxtension.xml
文件中,如下所示:
<extensions>
<path dir='${HYBRIS_BIN_DIR}' autoload='false' />
<extension name='mcc' />
<extension name='adaptivesearchsolr' />
<extension name='adaptivesearchbackoffice' />
<extension name='adaptivesearchsamplesaddon' />
<extension name='commerceservicesbackoffice' />
<extension name='solrfacetsearchbackoffice' />
<extension name='solrserver' />
<!-- <extension name='yacceleratorcockpits' /> -->
<!-- <extension name='yacceleratorinitialdata' /> -->
<!-- <extension name='yacceleratorstorefront' /> -->
<extension name='ycommercewebservices' />
<extension name='ycommercewebservicestest' />
<extension name='electronicsstore' />
<extension name='apparelstore' />
<extension name='captchaaddon' />
<extension name='liveeditaddon' />
<extension name='acceleratorwebservicesaddon' />
<extension name='commerceorgsamplesaddon' />
<extension name='orderselfserviceaddon' />
<extension name='rulebuilderbackoffice' />
<extension name='couponbackoffice' />
<extension name='droolsruleengineservices' />
<extension name='couponfacades' />
<extension name='promotionenginesamplesaddon' />
<extension name='assistedservicestorefront' />
<extension name='assistedserviceyprofileaddon' />
<extension name='assistedservicecustomerinterestsaddon' />
<extension name='assistedservicepromotionaddon' />
<extension name='customerticketingaddon' />
<extension name='customersupportbackoffice' />
<extension name='eventtrackingwsaddon' />
<extension name='hybrisanalyticsaddon' />
<extension name='yprofileeventtrackingws' />
<extension name='yprofileeventadapter' />
<extension name='yprofileprocessadapter' />
<extension name='privacyoverlayeraddon' />
<extension name='yaasconfigurationbackoffice' />
<extension name='textfieldconfiguratortemplatebackoffice' />
<extension name='textfieldconfiguratortemplateaddon' />
<extension name='cmswebservices' />
<extension name='smarteditwebservices' />
<extension name='cmssmarteditwebservices' />
<extension name='permissionswebservices' />
<extension name='smarteditaddon' />
<extension name='cmssmartedit' />
<extension name='consignmenttrackingaddon' />
<extension name='consignmenttrackingmockaddon' />
<extension name='consignmenttrackingbackoffice' />
<extension name='notificationaddon' />
<extension name='customerinterestsaddon' />
<extension name='stocknotificationaddon' />
<extension name='configurablebundleaddon' />
<extension name='previewpersonalizationweb' />
<extension name='personalizationcmsweb' />
<extension name='personalizationsmartedit' />
<extension name='personalizationsampledataaddon' />
<extension name='personalizationyprofile' />
<extension name='personalizationpromotions' />
<extension name='personalizationpromotionsweb' />
<extension name='personalizationservicesbackoffice' />
<extension name='personalizationpromotionsbackoffice' />
<extension name='personalizationcmsbackoffice' />
<extension name='personalizationintegrationbackoffice' />
<extension name='assistedserviceatddtests' />
<extension name='promotionengineatddtests' />
<extension name='textfieldconfiguratortemplateatddtests' />
<extension name='configurablebundleatddtests' />
<extension name='configurablebundlecockpits' />
<extension name='pcmbackofficesamplesaddon' />
<extension name='mcc' />
<extension name="hmc" />
<extension name='trainingcockpits'/>
<extension name='trainingcore'/>
<extension name='trainingfacades'/>
<extension name='trainingfulfilmentprocess'/>
<extension name='traininginitialdata'/>
<extension name='trainingstorefront'/>
<extension name='trainingtest'/>
<extension name='trainingbackoffice'/>
</extensions>
我为小部件创建了一个控制器,如下所示:
package org.training.widgets.mysearch;
import java.util.List;
import org.training.service.SearchService;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Textbox;
import com.hybris.cockpitng.annotations.ViewEvent;
import com.hybris.cockpitng.util.DefaultWidgetController;
/* @author scharafi
*
*/
public class MySearchController extends DefaultWidgetController
{
private Textbox searchInput;
@WireVariable
private SearchService searchService;
@ViewEvent(componentID = "searchBtn", eventName = Events.ON_CLICK)
public void doSearch() throws InterruptedException
{
final List<String> result = searchService.search(searchInput.getText());
Messagebox.show(result.get(0));
}
public Textbox getSearchInput()
{
return searchInput;
}
public void setSearchInput(final Textbox searchInput)
{
this.searchInput = searchInput;
}
public SearchService getSearchService()
{
return searchService;
}
public void setSearchService(final SearchService searchService)
{
this.searchService = searchService;
}
}
我在definitions.xml中添加了控制器,如下所示:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<widget-definition id="org.training.widgets.mysearch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/widget-definition.xsd">
<controller class="org.training.widgets.mysearch.MySearchController"/>
<name>My Search</name>
<description>My own search widget.</description>
<defaultTitle>Search</defaultTitle>
<author>CHARAFI Saad</author>
<version>0.1</version>
</widget-definition>
运行命令ant clean之后,所有构建都没有通过。
错误在控制台中显示如下:
[yjavac] 1. ERROR in C:\hybris\hybris\bin\custom\trainingbackoffice\src\org\training\widgets\mysearch\MySearchController.java (at line 6)
[yjavac] import org.zkoss.zk.ui.event.Events;
[yjavac] ^^^^^^^^^
[yjavac] The import org.zkoss cannot be resolved
该错误适用于zul的所有导入
更新:
以下是extensioninfo.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<extensioninfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="extensioninfo.xsd">
<extension abstractclassprefix="Generated" classprefix="Trainingbackoffice" managername="TrainingbackofficeManager" managersuperclass="de.hybris.platform.jalo.extension.Extension" name="trainingbackoffice" usemaven="false">
<!-- you should add all required extensions to this list, except platform extensions which are automatically required -->
<!-- <requires-extension name="cms"/> -->
<requires-extension name="backoffice"/>
<coremodule generated="true" manager="org.training.jalo.TrainingbackofficeManager" packageroot="org.training"/>
<meta key="backoffice-module" value="true"/>
</extension>
答案 0 :(得分:3)
您的类是在全局上下文中定义的,但ZK Framework仅在后台上下文中可用。
扩展结构:
src
←全局上下文(所有扩展都可以使用它)backoffice/src
←后台上下文(只有后台扩展可以使用它)将依赖于ZK Framework的类从src
移动到backoffice/src
。
为什么ZK Framework仅在后台环境中可用? Backoffice是一个Web应用程序,可以使用位于lib
和web/webroot/WEB-INF/lib
目录中的库。 ZK类位于web/webroot/WEB-INF/lib
目录中。后台扩展(backoffice/src
)被加载到Web上下文中,这就是他们可以使用ZK Framework的原因。 src
中定义的类只能使用位于lib
目录中的库,因此ZK类不可用。
答案 1 :(得分:2)
您如何创建自定义后台扩展程序。您是否使用过var timer = null; // This will hold the most recent timer's id
function jump() {
clearTimeout(timer); // Cancel any previous timer
let time = randomTime(1000, 2000);
let hole = randomHole(holes);
console.log(time, hole);
hole.classList.add('up');
// Capture a reference to the most recent timer
timer = setTimeout(() => {
hole.classList.remove('up');
debugger;
jump();
}, time);
}
模板?
这个问题似乎与依赖问题有关。请验证您的extensioninfo.xml文件。您应该具有后台扩展的依赖性。
extensioninfo.xml ...
ybackoffice
答案 2 :(得分:0)
您可以在安装程序中检查zkoss库是否存在,并且在构建过程中没有被错误删除。有时这会导致导入问题。如果这是问题所在,则需要在设置过程中添加所有缺少的库,您将可以继续进行。希望这可以解决您的问题!