Dear list,
I want to dynamically add and remove items to an Accordion.
I have the addition working (Concepts is the name of my Accordion) and in it I want to show a tree. This behavior is called from a menuBar. The only trouble is that the id of the tree gets duplicated. Any help on that would be appreciated:
<d:handler event="mouseup">
<c:create
destination="id('Concepts')">
<b:accordionItem label="new Concept">
<b:tree id="techtree">
<b:treeBranch label="Concept" open="true">
</b:treeBranch>
</b:tree>
</b:accordionItem>
</c:create>
</d:handler>
</d:behavior>
Deletion, however, is something I cannot get to work. My current code (most of it from the contextMenu example) fails with: 'Command destroy cannot be executed in the current context':
<d:handler event="mouseup">
<c:trace select="id('Concepts')/property::selectedIndex"/>
<c:destroy with="id('Concepts')/property::selectedIndex"/>
</d:handler>
</d:behavior>
The trace shows the correct number of the selected AccordionItem. But the eclipse XML editor puts red wrinkles under the with attribute and it says it is not allowed to appear in a c:destroy element....
What am I missing here?
Any help will be appreciated.
Kind regards,
Jan

Another way that does not work:
17 September, 2007 - 16:55 — Jan H van der Ven<d:handler event="mouseup">
<c:trace select="id('Concepts')/property::selectedIndex"/>
<e:with select="id('Concepts')/property::selectedIndex">
<c:destroy />
</e:with>
</d:handler>
</d:behavior>
Error: Command destroy cannot be used in the specified context.
I could really use some help with this...
Regards,
Jan
More news
17 September, 2007 - 18:43 — Jan H van der VenAfter dinner, I had a revelation and tried:
<d:handler event="mouseup">
<e:if test="id('Concepts')/property::selectedIndex">
<c:destroy with="id('Concepts')/property::elements[id('Concepts')/property::selectedIndex]"></c:destroy>
</e:if>
</d:handler>
</d:behavior>
And that removed all AccordionItems....
Then I tried:
And that removed all AccordionItems too....
I am not making progress.
Regards,
Jan
First working version...
17 September, 2007 - 19:19 — Jan H van der Ven<d:handler event="mouseup">
<e:for-each select="id('Concepts')/property::elements">
<e:if test="./property::selected">
<c:destroy />
</e:if>
</e:for-each>
</d:handler>
</d:behavior>
So, in this case I have to loop over all AccordionItems (even though the Accordion itself knows the selectedIndex) to find the one that is selected and destroy that.
There must be a better way.
Regards,
Jan