刚上acordeon Primefaces的标签更新标签、acordeon、Primefaces

2023-09-11 22:33:02 作者:兩嗰亽

我有标签的动态数字手风琴。标签名称被置到一个CSS类。这使得阉绿色或红色背景,取决于如在命令所有的文章都发表。

I have an accordion with a dynamic number of tabs. The tab title get set to an css class. This makes the background wether green or red, depends on if all the articles in the order are delivered.

有关每篇文章有一个selectBooleanButton和这些按钮的实际标签应该得到更新的每一个变化。

For every Article there is a selectBooleanButton and on every change of these Buttons the actual tab should get updated.

现在的问题是:我如何更新只是一个标签?当我更新整个手风琴的第一个选项卡中打开另一个得到封闭。

The problem is: How can I update just one tab? When i update the whole accordion the first tab opens and the other get closed.

<p:accordionPanel id="ordersAccordion" cache="true" value="#{ordersBean.orders}" var="order">
        <p:tab
            titleStyleClass="#{ordersBean.isOrderDelivered(order) ? 'ui-accordion-tab-delivered' : 'ui-accordion-tab-undelivered'}"
            title="##{order.order_id} | #{order.printableOrderDate}  | #{order.printableOrderTime} | #{order.user} | #{order.getDestination().toString()}">
            <p:dataTable value="#{order.demands}" var="demand">
                <p:column headerText="Artikel Nr.">
                    <p:outputLabel value="#{demand.article.articleNumber}" />
                </p:column>
                <p:column headerText="Name">
                    <p:outputLabel value="#{demand.article.name}" />
                </p:column>
                <p:column headerText="Beschreibung">
                    <p:outputLabel value="#{demand.article.description}" />
                </p:column>
                <p:column headerText="Haus">
                    <p:outputLabel value="#{demand.house.getLabel()}" />
                </p:column>
                <p:column headerText="Anzahl">
                    <p:outputLabel value="#{demand.quantity}" />
                </p:column>
                <p:column headerText="Mitarbeiter">
                    <p:outputLabel value="#{demand.employee}" />
                </p:column>
                <p:column headerText="Lieferstand" width="150" style="text-align: center">
                    <p:selectBooleanButton id="deliverdBtn" value="#{demand.delivered}" onLabel="Geliefert" offLabel="Geliefert" onIcon="ui-icon-check"
                        offIcon="ui-icon-close">
                        <p:ajax listener="#{ordersBean.saveDelivered(demand)}" update=":allOrders:ordersAccordion" />
                    </p:selectBooleanButton>
                </p:column>
            </p:dataTable>
        </p:tab>
    </p:accordionPanel>

感谢您的帮助

Thanks for help

推荐答案

该AccordionPanel有一个activeIndex属性,你可以用它来工作,当前选项卡中。你应该能够做这样的事情:

The AccordionPanel has an activeIndex attribute which you can use to work on the current tab. You should be able to do something like this:

<p:ajax listener="#{ordersBean.saveDelivered(demand)}" update=":allOrder:ordersAccordion:tab#{ordersAccordion.activeIndex}" />