Reputation: 7
i have entity FDataTableColumn which has field referenceFieldId which is long type and refs onto id of such column. On the create page i have combobox with list of all columns, i want to chose one and to put its id value to my referenceFieldId. this is my combobox:
<combobox model="@load(fdtcm.fDataTableColumns)" selectedItem="@bind(fdtcm.fDataTableColumn.referenceFieldId)" width="50%">
<template name="model">
<comboitem label="@load(each.table.tableName.concat('.').concat(each.tableField))" value="@bind(each.id)"/>
</template>
</combobox>
Looks like it's all good but i got this exception
Cannot convert FDataTableColumn{id=6, type=STRING, tableField='EMAIL'} of type class ru.webvane.framework.metadata.entity.FDataTableColumn to class java.lang.Long at [file:/E:/apache-tomcat-7.0.28%20(64)/webapps/fw/fw/importData/dataTableColumn/input.zul, line:86]
i understand that my combo is trying to save the whole object to referenceFieldId, but why ? because i'm trying to save object's id
value="@bind(each.id)"
can anyone help me or explain what i'm doing wrong. thank you
Upvotes: 0
Views: 2854
Reputation: 4277
SergeBud,
It is possible to do so but as askkuber already points out, the class of what's inside the combobox is the class what will be saved.
Now you just have to implement your own custom converter :
then it should the zul be like :
selectedItem="@bind(fdtcm.fDataTableColumn.referenceFieldId) @converter(fdtcm.myConverter)"
Upvotes: 2
Reputation: 607
You can check following code which written by me zkframeworkhint.blogspot.in/2013/05/zk-combobox-with-selectoption.html this will explain you the right way to use Combobox.
EDIT :-
Then you can check this link Combobox this will help you
Look selectedItem should be object of the class FDataTableColumn but in you case you refer it as id which is Long it could be a reason of the exception make changes in your code.
Upvotes: 0