How do I edit a List<String> within a listbox directly?

asked 2015-11-18 02:23:25 +0800

KlausWr gravatar image KlausWr
37 5

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>();

    public void init() {

    public List<String> getList() {
        return list;


    <vbox apply="org.zkoss.bind.BindComposer"
        viewModel="@id('vm') @init('experiment.EditableListboxViewModel')">

        <listbox model="@bind(vm.list)">
            <template name="model">
                        <textbox value="@bind(each)" />

I also tried the following (as I thought an immutable string might be the problem):

public void init() {
    list.add(new String("test"));   
    list.add(new String("test"));   
delete flag offensive retag edit


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 )edit

http://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 )edit

I'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

1 Answer

Sort by ยป oldest newest most voted

answered 2015-11-18 10:00:39 +0800

Darksu gravatar image Darksu
1991 1 4

Hello KlausWr,

I found the following fiddle that uses a grid:


Between us using a pojo probably is the best method from a design perspective.

Best Regards,


link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2015-11-18 02:23:25 +0800

Seen: 43 times

Last updated: Nov 18 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More