Search code examples
zkzul

ZK framework getting value of a component on zul page


I am trying to get the value of a textbox on a zul page by using some kind of getValue method. I should handle this on the zul page, not on a controller. I need to assign a listbox cell (which is the first cell of the list box below) with a value coming from the textbox.

    <listcell>
        <label value="" />
    </listcell>

    <listcell>
        <toolbarbutton visible="true"
            image="/resources/images/icons/1616/page_text.gif" />
    </listcell>

    <listcell>
        <label value="@{file.name}" />
    </listcell>

    <listcell>                           
        <toolbarbutton forward="onClick=onRemoveMultipleFiles"
            visible="true" id="newFileAndCommentRemove" image="/resources/images/icons/1616/delete.png" />
    </listcell>
</listitem>


Solution

  • If what you want is that after the textbox is filled then the first cell will fill with its value you can do it like this:

    1. put an id into the label in the cell
    2. put an onChange operation in the textbox so when the textbox change you can put its value into the cell

    like this:

    <textbox id="textbox" onChange="label.setValue(self.getValue())"/>
    <listbox id="newFileAndComment">
    <listhead>
        <listheader label="1" width="30px" />
    </listhead> 
    <listitem self="@{each=file}">
        <listcell>
            <label id="label"/>
        </listcell>
    </listitem>