-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have a Chosebox i am completely new to this api i select some items but i couldn't find back i mean i have try
BindingListModelList getSelection()
but returns empty i have try
chosen.getSelectedObjects()
I follow this example http://www.zkoss.org/zkdemo/zkpeandee/comboboxchosenbox but i could not find a way to retrieve the selected objects.
but nothing worked any tip thanks a lot.
UPDATE I was using a ItemRender like this
public final class CustomChoseBoxRender implements org.zkoss.zul.ItemRenderer<NotNullIntegerStringEntry>
{
public String render(final Component owner,final NotNullIntegerStringEntry data,final int index) throws Exception
{return data.getValue();}
}
when i set the render to the chosenbox the getSelection() method always return a empty set.
box.setItemRenderer(new CustomChoseBoxRender());
<chosenbox itemRenderer="@{render}"/>
I have try to set it in both java and in and zul but the results are the same.
Is this a bug any workaround?
I have create a Fiddle as show this bug in 6.5.3 but works ok in 7.5.1
http://zkfiddle.org/direct/13sio2p/1/v6.5.3-Chosebox-getSelection?run=2vphvaf
hi Javiut:
It's best to use a model to do all the operation instead of using a component.
Because a model has deal with all the possible situations, using a component would break the operations a model do.
Here is an example.
<zk>
<hlayout apply="org.support.simulate6.MailContactsController">
<chosenbox id="contacts" width="100px" />
<button id="send" label="print" />
</hlayout>
<label id="output"/>
</zk>
public class MailContactsController extends SelectorComposer<Component> {
@Wire("#contacts")
private Chosenbox contactsbox;
@Wire("#output")
private Label output;
private ListModelList<String> contacts;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
contacts = new ListModelList<String>();
contacts.add("[email protected]");
contacts.add("[email protected]");
contacts.add("[email protected]");
contactsbox.setModel(contacts);
}
@Listen("onClick=#send")
public void send() {
String contact = "";
Iterator<String> contactInter = contacts.getSelection().iterator();
while (contactInter.hasNext()) {
contact += contactInter.next();
contact += " ";
}
output.setValue(contact);
}
}
Asked: 2015-10-01 20:53:37 +0800
Seen: 21 times
Last updated: Oct 03 '15
wrong valueException come in front of modal popup [closed]
Use parameters in a conditional @command
Problems with multiple press and onCtrlKey
MVVM @save on the fly [closed]
Unable to activate destroyed desktop
org.zkoss.zk.ui.UiException: java.lang.ClassNotFoundException
How to put a image or Letter over image on a specific XY Coordinate