How do you reference a zul component with an dynamic id, like id="calendarDecorate_${vmStatus.index}"?

时间:2018-10-02 09:11:55

标签: zk

I have method in class

public class CalendarDecorate {
 public void setDays(final boolean checkDays){
  //code
}}

In my zul file, i have a own component for this class:

<div>
  <calendarDecorate id="calendarDecorate_${vmStatus.index}"</calendarDecorate>
  <combobox onChange="calendarDecorate_${vmStatus.index}.setDays(payment.Code)"/>
</div>

Is there a notation that allows this reference calendarDecorator_${vmPaymentStatus.index}.setDays(payment.Code) to work?

1 个答案:

答案 0 :(得分:0)

如果只有一个<calendarDecorate>,则可以按组件类型进行布线

@Wire("calendardecorate")

由于您在id中附加了索引,所以我想有多个<calendarDecorate>。您可以 Wiring a Collection,并使用索引vmStatus.index引用其中之一。

如果您以MVVM模式进行开发,通常不需要获取组件参考。只需将相应的属性绑定到属性,例如

<calendarDecorate days="@load(vm.payment.code">