-
FEATURED COMPONENTS
First time here? Check out the FAQ!
<listitem>
<listcell label="${forEachStatus.index+1}" />
<listcell label="${each.deptName}" />
<listcell label="${each.posName}" />
<listcell label="${each.userName}" />
<listcell>
<label
value="${$composer.loadLabelProcessType(each.processType)}" />
<image src="/Share/img/icon/user.gif"
width="20px" height="20px" tooltiptext="Đổi vai trò">
<attribute name="onClick">
self.previousSibling.setValue($composer.onChangeProcessType(each.processType));
</attribute>
</image>
</listcell>
</listitem>
self.previousSibling.setValue($composer.onChangeProcessType(each.processType));
When the image receives a click event, it will change label's value. But I can't use "each" in el expression, zk show an error: "each cannot be resolved to a variable". What's wrong? I tried many way but not solve the problem:
- self.previousSibling.setValue($composer.onChangeProcessType(${each.processType}));
- self.previousSibling.setValue(${$composer.onChangeProcessType(each.processType)});
- ${self.previousSibling.setValue($composer.onChangeProcessType(each.processType))};
I may be wrong, but my understanding is that the EL expression is evaluated when the page is being composed. The onClick callback is executed after the page has been rendered. The EL variable "each" is already no longer available during the onClick event.
What I've done in a similar case of my own is to save the "each" value inside a custom attribute at the time when the page is composed. In the callback method, you can get the custom attribute value back. Something like below but you have to try and modify it:
<image>
<custom-attributes myELvalue="${each.processType}"/>
<attribute name="onClick">
var value = self.getAttribute("myELvalue");
self.previousSibling.setValue($composer.onChangeProcessType(value));
</attribute>
</image>
Asked: 2014-12-01 02:33:57 +0800
Seen: 30 times
Last updated: Dec 02 '14