Update problem with <p:splitButton> in PrimeFaces 5

UI Components for JSF
Post Reply
scths
Posts: 8
Joined: 06 Jun 2014, 12:27

06 Jun 2014, 13:06

Hi,

I am encountering an update problem with the <p:splitButton> component. Below is a simple example which works in 3.5.19 and 4.0.14 but no longer does in 5.0 or 5.0.1 of PrimeFaces. It consists of a single page with a <p:splitButton> containing three menu items. Additionally there are three checkboxes which should enable or disable the menu items.

In 3.5.19 and 4.0.14 altering a checkbox and then expanding the button shows the proper state of the menu items. However, if I alter a checkbox using 5.0 or 5.0.1 nothing happens. The button always retains the state it had when the page was loaded (when you load the example the first time: all items are enabled).

When looking at the generated HTML code in FireBug it seems that there is a div-element on the root level which basically represents the expandable panel of the button containing the menu items. In 3.5.19 and 4.0.14 this div is updated accordingly once I alter the checkboxes. In 5.0 or 5.0.1 altering the checkboxes (and thus updating the <p:splitButton>) seems to produce an additional div for each update. A full page reload fixes the problem temporarily by removing all but one of the divs which then reflects the proper state of the menu items according to the backing bean.

We are using JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8) with Mojarra 2.1.21. I encountered this behaviour in FireFox 29 and IE 11.

The backing bean:

Code: Select all

import java.io.Serializable;

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

@Named("testSplitButton")
@SessionScoped
public class SplitButton implements Serializable
{
  private boolean menuItem1Disabled;
  private boolean menuItem2Disabled;
  private boolean menuItem3Disabled;

  public boolean isMenuItem1Disabled()
  {
    return menuItem1Disabled;
  }

  public void setMenuItem1Disabled(boolean b)
  {
    this.menuItem1Disabled = b;
  }

  public boolean isMenuItem2Disabled()
  {
    return menuItem2Disabled;
  }

  public void setMenuItem2Disabled(boolean b)
  {
    this.menuItem2Disabled = b;
  }

  public boolean isMenuItem3Disabled()
  {
    return menuItem3Disabled;
  }

  public void setMenuItem3Disabled(boolean b)
  {
    this.menuItem3Disabled = b;
  }
}
The XHTML page:

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:p="http://primefaces.org/ui">

  <f:view>

    <h:head>
    </h:head>

    <h:body>

      <h:form id="mainForm">

        <h:panelGroup id="splitButtonPanel">

          <p:splitButton id="splitButton"
            value="SplitButton">
            <p:menuitem id="menuItem1"
              value="Item 1"
              disabled="#{testSplitButton.menuItem1Disabled}" />
            <p:menuitem id="menuItem2"
              value="Item 2"
              disabled="#{testSplitButton.menuItem2Disabled}" />
            <p:menuitem id="menuItem3"
              value="Item 3"
              disabled="#{testSplitButton.menuItem3Disabled}" />
           </p:splitButton>

        </h:panelGroup>

        <h:panelGrid columns="2">

          <h:outputLabel value="Item 1 disabled" />

          <p:selectBooleanCheckbox id="cbMenuItem1"
            value="#{testSplitButton.menuItem1Disabled}">
            <p:ajax event="change"
              update="mainForm:splitButtonPanel" />
          </p:selectBooleanCheckbox>

          <h:outputLabel value="Item 2 disabled" />

          <p:selectBooleanCheckbox id="cbMenuItem2"
            value="#{testSplitButton.menuItem2Disabled}">
            <p:ajax event="change"
              update="mainForm:splitButtonPanel" />
          </p:selectBooleanCheckbox>

          <h:outputLabel value="Item 3 disabled" />

          <p:selectBooleanCheckbox id="cbMenuItem3"
            value="#{testSplitButton.menuItem3Disabled}">
            <p:ajax event="change"
              update="mainForm:splitButtonPanel" />
          </p:selectBooleanCheckbox>

        </h:panelGrid>

      </h:form>

    </h:body>

  </f:view>

</html>

scths
Posts: 8
Joined: 06 Jun 2014, 12:27

10 Jun 2014, 15:08

The problem still exists in 5.0.2 while 4.0.15 works fine.

LarsB
Posts: 7
Joined: 28 May 2014, 12:28
Location: Germany

24 Jun 2014, 10:16

I also encountered an update problem with SplitButton. Perhaps it is the same main problem.
http://forum.primefaces.org/viewtopic.php?f=3&t=38639
PrimeFaces 5.0 | Tomcat 6.0.36 | Mojarra 2.2.1 | Firefox 28.0

mashama
Posts: 13
Joined: 13 Mar 2014, 06:43

09 Jul 2014, 06:40

I also have the same problem. I cannot update content within the dropdown of a split button. Running Wildfly 8.1.Final with Mojarra 2.2.6-jbossorg-4.
Primefaces 5.4
Wildfly 10
OS X and CentOS 7

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

09 Jul 2014, 09:47

Please file an issue

scths
Posts: 8
Joined: 06 Jun 2014, 12:27

09 Jul 2014, 09:57

Apparently someone already did and even referenced this topic: https://code.google.com/p/primefaces/is ... il?id=7046

Just FYI: The behaviour hasn't changed in 5.0.3 (still works in 4.0.16).

vished
Posts: 479
Joined: 02 Feb 2014, 17:38

16 Oct 2014, 21:07

is the issue still open in 5.1 ?
It seems so for me, can you give me some feedback, please.
PF 8.0

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

17 Oct 2014, 09:35

What feedback? If the issue is still open, it is still open

scths
Posts: 8
Joined: 06 Jun 2014, 12:27

27 Oct 2014, 10:39

Sorry for the late reply, I was on a vacation. Apparently I missed the notification about the issue being fixed in July. Sorry for that, too.

I checked the original sample code with 5.0.4 and 5.1 and it seems to work now. Thank you.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 53 guests