1

Exception javassist with Form Binding + Status.dirty + Combobox + Hibernate

asked 2014-09-01 09:09:36 +0800

sarco gravatar image sarco flag of Spain
93 6
https://github.com/sarcow...

updated 2014-09-01 11:02:57 +0800

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?

delete flag offensive retag edit

Comments

But we would need Hibernate for it...

sarco ( 2014-09-01 13:17:19 +0800 )edit

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

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-09-15 22:14:58 +0800

mhlic gravatar image mhlic
38 3

updated 2014-09-15 22:15:30 +0800

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()
link publish delete flag offensive edit

Comments

Thank you very much, now it's working fine.

sarco ( 2014-09-15 23:09:10 +0800 )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: 2014-09-01 09:09:36 +0800

Seen: 26 times

Last updated: Sep 15 '14

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