1

i have a for each in my zk page, and in the each i am creating a column, and in my column i need add a iframe, and to each frame i need pass as variable the label of the column.

I have something like:

<zk>
          <window title="Dynamic Columns" border="normal" width="1824px" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('pkg$.DynamicColumnModel')">
<grid >

               <columns>
                  <column forEach="${vm.columnList}" label="${each}">

              <iframe 
        src="test.zul" />
                </column>
              </columns>
     </grid>
   </window>
</zk>

But i have an error when i include the page, and my first problem is that i do not know how can i pass a variable to each iframe.

And my java is something like:

public class DynamicColumnModel {

private List<String> columnList = new ArrayList<String>();
 private String texto="123";

@Init
public void init(){

    columnList.add("Dynamic Col A");
    columnList.add("Dynamic Col B");
    columnList.add("Dynamic Col C");
    columnList.add("Dynamic Col D");
}

public List<String> getColumnList() {
    return columnList;
}
public void setColumnList(List<String> columnList) {
    this.columnList = columnList;
}

 public String getTexto() {
    return texto;
}
public void setTexto(String texto) {
    this.texto = texto;
}


@Command
   public void mensaje(){

  }

}

Thanks

4

1 回答 1

1

如果您each是 a String,就像您将其设置为列标签一样,请继续并将其作为 URL 参数传递给iframe.

    <window apply="org.zkoss.bind.BindComposer"
            viewModel="@id('vm') @init('pkg$.DynamicColumnModel')">
        <grid >
            <columns>
                <column forEach="${vm.columnList}" label="${each}">
                    <iframe src="test.zul?myValue=${each}" />
                </column>
            </columns>
        </grid>
   </window>

请注意,当您使用iframe组件时,您是在 ZK 之外。确实,它iframe本身指向一个 ZK 页面,但它不是在同一个 ZK 环境中。iframe可以很容易地包含,因此www.google.com没有特定的 ZK 支持将值传递给以这种方式包含的 ZK 页面。

如果您只包含 ZK 页面并希望更流畅地向这些页面传递信息,您将需要使用 ZK 的include标签。查看有关如何将值传递给包含的 ZK 页面的文档。

编辑
如果走这条路,您可以使用 ZK 的类iframe访问 URL 参数值:test.zulExecution

Execution execution = Executions.getCurrent();
execution.getParameter("myValue");
于 2013-10-10T12:13:19.233 回答