在ZK中使用按钮调用窗口

时间:2013-09-24 13:33:18

标签: java forms zk zk-grid

我有这段代码:

<?xml version="1.0" encoding="UTF-8"?>

    <zk>
        <style src="/widgets/grid/inline_row_editing/style.css" />
        <div apply="org.zkoss.bind.BindComposer"
     viewModel="@id('vm')     @init('com.gemalto.segmentation.viewModel.users.InplaceEditingViewModel')">

    <window id="MnoNEWin" title="Mnos" width="300px" visible="false" minimizable="true" border='normal'>
        <listbox id="listNE" model="@bind(each.mnoList)" >
            <listhead>
                <listheader label="Mnos" sort="auto" />
            </listhead>
        </listbox>
    </window> 

    <grid id="demoGrid"
          model="@load(vm.languageContributions) @template((vm.displayEdit and     each.editingStatus) ? 'editable' : 'noneditable')">
        <auxhead>
            <auxheader colspan="4"
                       label="Create Users">
                <hlayout>
                    <label />
                    <button label="create" 
                            onClick="@command('onAddNew', languageContributionStatus=each)" />
                    <checkbox checked="@bind(vm.displayEdit)"
                              label="Enable Multiple Inline Row Editing">
                    </checkbox>
                </hlayout>
            </auxheader>
        </auxhead>

        <columns>
            <column width="160px">Email</column>
            <column width="160px">Password</column>
            <column width="160px">Confirm-Password</column>
            <column width="160px">Role</column>
            <column width="160px">Mnos</column>
            <column width="110px" visible="@load(vm.displayEdit)">Edit</column>
            <column width="110px" visible="@load(vm.displayEdit)">Remove</column>
        </columns>
        <rows>
            <template name="editable">
                <row>
                    <textbox
                        value="@load(each.languageContribution.email)
    @save(each.languageContribution.email, before='confirm')" /> <textbox     value="@load(each.languageContribution.password) @save(each.languageContribution.password,     before='confirm')"/> 
<textbox value="@load(each.languageContribution.password)         @save(each.languageContribution.confirmPass, before='confirm')"/> 
<textbox value="@load(each.languageContribution.role)     @save(each.languageContribution.role, before='confirm')"/>

                    <button id="MnoE" label="Mnos"/>

                    <window id="MnoEWin" title="Mnos" width="300px" visible="false"     minimizable="true" border='normal'>
                        <listbox id="listNE" model="@bind(each.mnoList)" >
                            <listhead>
                            <listheader label="Mnos" sort="auto" />
                            </listhead>
                        </listbox>
                    </window> 

                    <button
                        label="save"
                        onClick="@command('confirm', languageContributionStatus=each)"     />
                    <button
                        label="cancel"
                        onClick="@command('changeEditableStatus2',     languageContributionStatus=each)" />


                </row>
            </template>


            <template name="noneditable">
                <row>
                    <label value="@load(each.languageContribution.email)" />
                    <label value="@load(each.languageContribution.password)" />
                    <label value="@load(each.languageContribution.password)" />
                    <label value="@load(each.languageContribution.role)" />

                    <button label="Mnos">
                        <attribute name="onClick"><![CDATA[
        if (!@load(each.languageContribution.email).isVisible())
            @load(each.languageContribution.email).setVisible(true);
        @load(each.languageContribution.email).doHighlighted();
    ]]></attribute>
                    </button>
                    <button
                        label="edit"
                        onClick="@command('changeEditableStatus', languageContributionStatus=each)" />

                    <window id="@load(each.languageContribution.email)"  title="Mnos"     width="300px" visible="false" minimizable="true" border='normal'>
                        <listbox id="listNE" model="@bind(each.mnoList)" >
                            <listhead>
                                <listheader label="Mnos" sort="auto" />
                            </listhead>
                        </listbox>
                    </window> 
                </row>
            </template>
        </rows>


    </grid>
</div>
</zk>

我有一个问题,因为在窗口

                <button label="Mnos">
                    <attribute name="onClick"><![CDATA[
    if (!@load(each.languageContribution.email).isVisible())
        @load(each.languageContribution.email).setVisible(true);
    @load(each.languageContribution.email).doHighlighted();
]]></attribute>
                </button>
                <button
                    label="edit"
                    onClick="@command('changeEditableStatus', languageContributionStatus=each)" />

                <window id="@load(each.languageContribution.email)"  title="Mnos" width="300px" visible="false" minimizable="true" border='normal'>
                    <listbox id="listNE" model="@bind(each.mnoList)" >
                        <listhead>
                            <listheader label="Mnos" sort="auto" />
                        </listhead>
                    </listbox>
                </window>

我需要点击按钮Mno窗口:

<window id="@load(each.languageContribution.email)"

出现了,但是窗口的每个用户都有一个id,而且我不知道如何为按钮调用窗口,就像弹出一样,如:

http://www.zkoss.org/zkdemo/effects/login_effect

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:1)

首先,这个

<attribute name="onClick"><![CDATA[
        if (!@load(each.languageContribution.email).isVisible())
            @load(each.languageContribution.email).setVisible(true);
        @load(each.languageContribution.email).doHighlighted();
    ]]></attribute>

不起作用,cos @load不会在这个地方评估。
如果您不知道id,可以使用zul结构获取Component

<button label="Mnos" onClick="@command('openWindow', window = self.nextSibling )">

in vm

 @Command
    public void openWindow(@BindingParam("window") Window win){
       if(!win.isVisible()){
          win.setVisible(true);
          win.doHighlighted();
       }
    }