Ah oke, Then you have to add an eventListener to onSelectet to you combobox and write there the logic in it. Need more explication of eventlistener? Greetz chill.
chillworld ( 2014-03-17 11:56:33 +0800 )edit-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
can someone help me how to add(generate) new combobox into zul page(groupbox) after i click on the button? At first i was thinking about generating all comboboxes when the zul page is generated and making them invisible, and after i click button set them visible, but its quiet uneffective.
this is how my page looks like:
zul source code:
...
<groupbox title="Moduly vo variante" width="700px" height="230px">
<vlayout>
<hlayout>
<textbox value="@bind(mevm.selectedModul11)" width="150px"/>
<label value="or:" visible="@bind(mevm.modul11Vis)" width="150px"/>
<textbox value="@bind(mevm.selectedModul12)" width="150px"/>
<button mold="trendy" label="+" visible="@bind(not mevm.modul12Vis)"
onClick="@command('addTextBoxHor')"/>
</hlayout>
<button mold="trendy" label="+" visible="@bind(not mevm.modul61Vis)"
onClick="@command('addTextBoxVert')"/>
</vlayout>
</groupbox>
...
Well, you could add the groupbox as parameter with your command like this :
<groupbox id="grpBox" title="Moduly vo variante" width="700px" height="230px">
....
<button mold="trendy" label="+" visible="@bind(not mevm.modul12Vis)"onClick="@command('addTextBoxHor', groupbox=grpBox)"/>
...
</groupbox>
then you will have your groupbox in your command like this :
@Command
public void addTextBoxHor(@BindingParam("groupbox") Groupbox grpBox) {
....
}
Now just create your combobox with code and put it in your groupbox where you want it.
If that is to hard, just create a dummy combobox and do the same but in stead of groupbox take the combobox. Just with the command you make it visible and fill its data.
Take care, if your data is not refreshed, it could be you have to do grpBox.invalidate();
at the end.
Greetz chill.
Thank you, it works! :) If i can have two more question...in zul page i did combobox like this:
<combobox width="150px" model="@load(mevm.modulsList)" selectedItem="@bind(mevm.selectedModul11)">
<template name="model">
<comboitem label="@load(each.name)"/>
</template>
</combobox>
1.how do i set that selected item from combbox will be saved into selectedModul11 and 2. how to set template of combobox that it will show attribute "name" in combobox? but in java code.
until now i have in java code something like this:
Combobox combobox = new Combobox();
combobox.setModel(new ListModelList(modulsList));
i tried
combobox.setSelectedItem(selectedModul11);
but it doesnt work.
Well,
You are doing it : selectedItem="@bind(mevm.selectedModul11)"
This means that when selectedItem is you will save it in mevm.selectedModul11.
@bind
is the same as @load @save
.
You can use a renderer. Then you have full control with java of what you can see.
Greetz chill.
But I am asking how can I get selectedItem from combobox in my java code :) (i know how to handle it if i create combobox in zul file) This is my situation: 1.I click button 2.I create new combobox which contains list of moduls:
Combobox combobox = new Combobox();
combobox.setModel(new ListModelList(modulsList));
Now have to select item from modulsList and save selected item into variable "selectedModul11", but my problem is that i dont know how to set combobox so it will save selected item into "selectedModul11". (in Java code)
i need something like this:
combobox.setSelectedItem(selectedModul11);
Ah oke, Then you have to add an eventListener to onSelectet to you combobox and write there the logic in it. Need more explication of eventlistener? Greetz chill.
chillworld ( 2014-03-17 11:56:33 +0800 )editAsked: 2014-03-17 07:50:17 +0800
Seen: 41 times
Last updated: Mar 17 '14
composite component help [closed]
EL in a forEach @command not working?
Different template for each grid row
Cardlayout animation is broken
Grid RowRender slow using 6.5.1 and sizable=true
setVisible(false), component will load or not
Decimalbox and doublebox value rounded on iPad
history management with page status