-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I know how to edit a List<pojo> by using a listbox. But when I try to use a listbox to edit a simple List<string>, I always get an exception
org.zkoss.zk.ui.UiException: java.lang.Long cannot be cast to java.lang.String
class EditableListboxViewModel:
public class EditableListboxViewModel {
List<String> list = new ArrayList<String>();
@Init
public void init() {
list.add("test");
list.add("test");
}
public List<String> getList() {
return list;
}
}
EditableListbox.zul:
<zk>
<vbox apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('experiment.EditableListboxViewModel')">
<listbox model="@bind(vm.list)">
<template name="model">
<listitem>
<listcell>
<textbox value="@bind(each)" />
</listcell>
</listitem>
</template>
</listbox>
</vbox>
</zk>
I also tried the following (as I thought an immutable string might be the problem):
@Init
public void init() {
list.add(new String("test"));
list.add(new String("test"));
}
Hello KlausWr,
I found the following fiddle that uses a grid:
http://zkfiddle.org/sample/skqfup/7-Array-binding-bug#source-1
Between us using a pojo probably is the best method from a design perspective.
Best Regards,
Darksu
Asked: 2015-11-18 02:23:25 +0800
Seen: 51 times
Last updated: Nov 18 '15
ZK MVVM Listbox Mold Paging - select first record on each page [closed]
listfoot and paging disappears when loading data
bandbox click image custom action
ListCell textbox password getValue
textbox setValue unary operators
Listbox with multiple/checkmark=true not working
problem listbox index can't reload properly after addnew and remove data.??
Klaus, is it possible to create a fiddle with this problem? the problem doesn't come from this part of code normally
chillworld ( 2015-11-18 06:32:32 +0800 )edithttp://temp.zkfiddle.org:8080/t651svt/1k96gre/6/ Does only fail with exception when run in 6.5 - but does not really work in 8. BTW: the original fiddle is here: http://zkfiddle.org/sample/1k96gre/7-How-do-I-edit-a-List-of-String-within-a-listbox-directly
KlausWr ( 2015-11-18 07:22:46 +0800 )editI'm actually not able to get it working in any version. The conversion in 6.5 is probably a bug what's resolved, but I can't change the value also directly, no matter what I try
chillworld ( 2015-11-18 08:47:07 +0800 )edit