0

Listbox and Beans, item's ID != index

asked 2012-05-24 08:31:38 +0800

juergenmw gravatar image juergenmw
79 1

Hi Guys

Yesterday I played around with Listbox and it's possibilities to add model/data.(see here)

I ended up with using AnnotateDataBinderInit and here is my current problem:
I've two Listboxes, both are being connected with different lists of Bean objects.

<listbox id="inputListbox" mold="select" model="@<composer.allInput>">
    <listitem self="@{each=objects}" value="@{objects}"> 
        <listcell label="@{objects.name}"/>
    </listitem>
</listbox>
<listbox id="typeListbox" mold="select" model="@<composer.allTypes>">
    <listitem self="@{each=objects}" value="@{objects}"> 
        <listcell label="@{objects.name}"/>
    </listitem>         
</listbox>

Now there is an onSelect Callback on inputListbox. When this is being called (when the selected item changes) I also want to change the typeListbox accordingly because the bean "input" has an foreign key to "type".
Now the problem is - it is easy to set an Listboxes index, but in my case ID != index.

The (complex) solution I thought about is to

1.) Get the Input Bean Object in onSelect and get the foreign key (ID of "type")
2.) Get all Listitems from typeListBox
3.) Iterate throu them and see which one matches the foreign key (ID)
4.) Remember the index of the matching ID
5.) Set this Index on typeListBox

This looks kind of ugly to me - any other ideas how to solve this?

Regards
juergenmw

delete flag offensive retag edit
Be the first one to reply this discussion!
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

RSS

Stats

Asked: 2012-05-24 08:31:38 +0800

Seen: 139 times

Last updated: May 24 '12

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