我在创建 zul 时尝试将参数传递给它:
.zul 文件:
<window xmlns="http://www.zkoss.org/2005/zul"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:zk="http://www.zkoss.org/2005/zk"
xmlns:ca="http://www.zkoss.org/2005/zk/client"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd "
border="normal"
closable="false"
position="center,center"
width="383px"
height="270px"
onCancel="self.detach();"
id="decisionCommentWindow"
title="${c:l('approvalTaskWindow.title')}"
use="handlers.ZulHandler">
<zk if="${isManufacturingKey}">
<checkbox id="checkbox_id" label="check" />
</zk>
</window>
创建 zul 的 java 代码:
...
Map args = new HashMap<String, Boolean>();
Boolean isManufacturing = true;
args.put("isManufacturingKey", isManufacturing);
ZulHandler window = Preconditions
.checkNotNull((ZulHandler) Executions.createComponents(
"/decision_comment_window.zul", null, args));
window.setTitle(decisionModel.getName() + " decision");
if (isManufacturing) {
Checkbox checkbox = (Checkbox) Path
.getComponent("/decisionCommentWindow/emergency_change_checkbox_id");
checkbox.setChecked(workflow.getEmergencyChange());//I have Null pointer here because checkbox is null
}
...
我这里有空指针。
你能帮我吗?
最佳答案
感受差异:
错误变体:
<zk if="${isManufacturingKey}">
右变体:
<zk if="${arg.isManufacturingKey}">
这个问题的原因可能是使用 zk 框架的旧版本 - 我不知道。
关于java - 变量不会从 java 代码传递到 zul,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21044703/