-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi everyone, I would like to use Form Binding for Validations and Status.dirty, but I'm having several problems with the Combobox and Hibernate.
This is the exception:
Exception Type: class org.zkoss.zk.ui.UiException
Exception: org.zkoss.zk.ui.UiException: I can't convert com.sarco.hibernate.MyClass@2896ac80 from class com.sarco.hibernate.MyClass to class com.sarco.hibernate.MyClass_$$_javassist_309 at [file:/E:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/sarco/WEB-INF/pages/myfile.zul, line:54]
My Form:
<window apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.sarco.AddEditMyClassVM')"
border="normal"
width="500px"
closable="true"
mode="modal"
onClose ="@command('closeWindow', event = event, status = fxStatus.dirty)"
onCancel="@command('closeWindow', event = event, status = fxStatus.dirty)"
form="@id('fx') @load(vm.selectedItem) @save(vm.selectedItem, before='save')">
And the combobox:
<combobox model="@load(vm.items)"
selectedItem="@bind(fx.object)"
value="@load(vm.selectedItem.value)"
constraint="no empty">
<template name="model">
<comboitem label="@load(each.value)" />
</template>
</combobox>
I get the exception when I select an item from the combobox.
Any ideas?
You have to unproxy your fx.object so that your list of objects to choose from will match type. Right now your fx.object is of type xxxx$$javassist and your list of objects for the combobox are of type xxxx. So the solution is to unproxy it.
Call this to unproxy it:
Object unproxied = ((HibernateProxy) o).getHibernateLazyInitializer().getImplementation()
Asked: 2014-09-01 09:09:36 +0800
Seen: 26 times
Last updated: Sep 15 '14
Please help me in form binding
Problem binding values to a composite component
How to access static member field of a class in zul without zscript
How can i load a constant in .zul
MVVM Validator: class not found ? [closed]
MVVM tab box - delay @load until tab pane displayed?
mvvm, load or save with after or before for seach command
how to fire an event when a variable value loaded through VM
But we would need Hibernate for it...
sarco ( 2014-09-01 13:17:19 +0800 )editDon't wory about that, hibernate has nothing to do with this problem. (cleaned our comments a little bit, hope you don't mind that)
chillworld ( 2014-09-01 13:42:45 +0800 )edit