0

Multiple selection using ListModelMap<Key, Obj>

asked 2013-08-01 14:38:37 +0800

salman1 gravatar image salman1 flag of United Kingdom
40 4

updated 2013-08-01 14:41:03 +0800

Hi,

My question regards multiple selection. In the documentation (Databinding> Collection and Selections > Multiple Selections) it mentions that to access the selected items we should bind selectedItems to a property whose type is Set. This works if the components model type is ListModelList, but I use a ListModelMap<key, obj="">.

If I implement

Set<Obj> selectedObjs = new HashSet<Obj>();

When trying to access the selectedItems in the view model I get an error: Obj cannot be cast to java.util.Map$Entry because i guess that there is incompatibitlity between sublasses of Set (like HashSet) and ListModelMap. Can you advise a solution to this, thanks

delete flag offensive retag edit

Comments

What is the purpose of using ListModelMap. Can you provide your scenario?

iamsudhir4u ( 2013-08-02 07:48:59 +0800 )edit

For example, I upload multiple files to the server, then display the uploaded file name in a Listbox. If I upload a file that has the same name, then the existing file is overwritten/replaced with the newer file. A ListModelMap replaces the entry (if the key is the filename) ListModelList doesn't

salman1 ( 2013-08-02 19:12:47 +0800 )edit

Anyone know how to resolve this?

salman1 ( 2013-08-13 11:51:23 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-08-20 16:58:36 +0800

salman1 gravatar image salman1 flag of United Kingdom
40 4

OK, I fixed this myself. It was a silly oversight on my part:

Set<Entry<Key, Obj>> set = new HashSet<Entry<Key, Obj>>()

must be used for ListModelMap

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
2 followers

RSS

Stats

Asked: 2013-08-01 14:38:37 +0800

Seen: 20 times

Last updated: Aug 20 '13

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