0

generic cast

asked 2013-02-21 10:38:02 +0800

karry gravatar image karry
12

updated 2018-04-26 09:24:29 +0800

Hi, ZK 6.5 had supported generic. It is great. But when I override components, it make some trouble. For example I use MyListitem to render in a Listbox. In before, the follow code is ok.

List<MyListitem> items = listbox.getItems();

But now, it will cause compile error. There are many codes have this problem. How could I solve this problem quickly? Thank you.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-02-21 10:55:39 +0800

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

What exception you are getting? And you can check Here this post will show how to use generic with Listbox

link publish delete flag offensive edit

Comments

Thanks !, But I am not using databind. And it does net cause exception, but compile error : Cannot cast from List<Listitem> to List<MyListitem>. And, above is just one case, All methods that return type is List<someComponent> seem to cause this problem.

karry ( 2013-02-22 00:31:01 +0800 )edit

It may be the Java limit that List<A> cannot cast to List<B> even if B inherit from A and the elements of List<A> is all B actually. So, how can I do ? Thanks.

karry ( 2013-02-22 00:34:41 +0800 )edit

I know I can do this: List<MyListitem> items = (List) listbox.getItems(); But there are many codes must to be fixed. Is this is the only way ? Thanks

karry ( 2013-02-22 00:46:58 +0800 )edit

Can you edit your question with Code

sjoshi ( 2013-02-22 17:25:23 +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: 2013-02-21 10:38:02 +0800

Seen: 29 times

Last updated: Apr 26

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