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;
}
}
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>