0

Combobox with zk error

asked 2013-09-26 02:41:33 +0800

daovallec gravatar image daovallec
11 2

updated 2013-09-27 06:25:44 +0800

I have this zk code:

<hbox pack="center" align="top" width="100%" height="400px">
<style src="/widgets/combobox/simple_combobox/css/simple_combo.css" />
<div apply="org.zkoss.bind.BindComposer" height="278px" width="443px"
 viewModel="@id('vm') @init('ShirtViewModel')">
    <separator spacing="40px" />
    <hbox>
        <vlayout>
            <separator/>
            <label value="Color" />
            <combobox id="cmbColor" width="150px"
                  model="@load(vm.names)" selectedItem="@bind(vm.iname)">
            </combobox>
        </vlayout>

    </hbox>
</div>
</hbox>

and i have this java class:

public class ShirtViewModel {
    private String iname, iSize;
    private  List<String> names = Arrays.asList("juan", "marcus", "pedro");
    private  List<String> sizes =  Arrays.asList("big", "little", "medium");

    public List<String> getNames() {
        return names;
    }

    public void setNames(List<String> names) {
        this.names = names;
    }

    public void setSizes(List<String> sizes) {
        this.sizes = sizes;
    }

    public List<String> getSizes() {
        return sizes;
    }

    @Init
    public void init() {
        setIname("juan");
        setiSize("big");
    }

    public String getIname() {
        return iname;
    }

    public void setIname(String iname) {
        this.iname = iname;
    }

    public String getiSize() {
        return iSize;
    }

    public void setiSize(String iSize) {
        this.iSize = iSize;
    }

And i have an error with this code and i do not know why?

The error that i have is, and i have like model my class, i do not know what happen:

org.zkoss.zk.ui.UiException: model of the databind combobox <combobox dyfq8#cmbcolor=""> must be an instanceof of org.zkoss.zkplus.databind.BindingListModel.[juan, marcus, pedro] org.zkoss.zkplus.databind.SelectedComboitemConverter.coerceToUi(SelectedComboitemConverter.java:129)

Somebody can help me, and say me how can i correct my error

Then in the following page is explained better my problem, that is that i have a page with users that i obtain to my database, later, each user has a list of Mno, then, i need a listbox with all Mno in my database (it is a query, and is in my DAO), and i need the in the listbox the selecteditem with the mno that the user has.

in this page: is my problem explained:

 forum. zkoss. org/question/88986/problem-with-listbox-selecteditem/
delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2020-07-16 01:55:54 +0800

olegzhem gravatar image olegzhem
1

I had the same problem. On my page was header

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>

I remove that string and combobox began to work correctly.

link publish delete flag offensive edit

Comments

this 'string' is a processing instruction, initializing the 'old' (now deprecated) data binding (now moved to zkplus-legacy.jar). It is sometimes needed for older projects. New projects using the MVVM databinding annotations (@id/@init/@load/@save/@bind) don't need this initializer.

cor3000 ( 2020-07-20 13:04:31 +0800 )edit
0

answered 2013-09-27 03:23:23 +0800

cor3000 gravatar image cor3000
6280 2 7

I copied your example into ZK fiddle, it worked immediately and I cannot reproduce the error you encounter.

Am I missing something?

Which ZK/Java version are you using?

Maybe you can adjust the example in fiddle, to reproduce the problem.

Robert

link publish delete flag offensive edit
0

answered 2013-09-26 11:40:46 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

How to work with ZK Combobox? zk-combobox-with-selectoption

zk-combobox-with-item-rendered

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

Follow
1 follower

RSS

Stats

Asked: 2013-09-26 02:41:33 +0800

Seen: 30 times

Last updated: Jul 16 '20

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