3
votes

I'm using Primefaces (version 3.0.1) p:tabView component, which displays dynamic number of tabs backed by a list in a model. Tabs inside TabView are closable. I'd like to remove list element associated with a tab by close event.

Here is my view:

<p:tabView id="tabView" var="iterator" value="#{bean.list}">
    <p:ajax event="tabClose"
        listener="#{bean.removeElement(iterator)}" process="@this" />

        <p:tab id="tab" closable="true">
            <h:outputText value="#{iterator.text}" />
        </p:tab>
</p:tabView>

My bean handler:

public void removeElement(Element e) {
    this.list.remove(e);
}

Element e is null in this case

I've also tried to use p:collector inside p:ajax element. There is example at primefaces.org showcase. According to it my event handler should look like

public void removeElement(TabCloseEvent event) {
    // ...
}

But I don't know how can I get associated with tab list element.

All answers will be appreciated. Thanks in advance

1

1 Answers

2
votes

public void removeElement(TabCloseEvent event) should be used, imo.

According to TabCloseEvent it has a method getData(). This should give you access to your model class. Disclaimer: I haven't used TabView the way you do yet, but it works this way for Primeface's Tree component (i.e. selection of a node). Could you post back your findings?