我在 ZK 中定义了一个自定义命令,并希望通过单击菜单项来调用它。
我看到我们可以定义一个 AuRequest 对象,但是找不到像我们在 JavaScript 中使用 zkau.send 函数那样发送这个 AuRequest 的方法。
有什么可能吗?如果没有,是否可以在 JavaScript 函数中定义 zkau.send 并在 MeunItem Click Event 中调用它?
public class MyCustomCommand extends Command
{
protected MyCustomCommand(final String id, final int flags)
{
super(id, flags);
}
@Override
protected void process(final AuRequest request)
{
System.out.println("Menu Item Click");
}
}
注册命令:
<bean id="myCustomCommand" class="com.test.commands.MyCustomCommand">
<constructor-arg value="onMenuEdit" />
<constructor-arg><util:constant static-field="org.zkoss.zk.au.Command.IGNORE_OLD_EQUIV"/></constructor-arg>
</bean>
和 MenuItem 事件
menuItem.addEventListener(Events.ON_CLICK, new EventListener()
{
@Override
public void onEvent(final Event event) throws Exception
{
final Tree tree = (Tree) parent;
final Treeitem treeitem = tree.getSelectedItem();
final AuRequest auRequest = new AuRequest(treeitem.getDesktop(), treeitem.getUuid(), "onMenuEdit", new String[]{});
//how to send the auRequest??
}
});