Time for action – using SplitButton
Let us see how we can use the <p:splitButton>
component, by performing the following step:
- Create a form with the
<p:splitButton>
component with My Account as the default action, and Change Password and Logout as other options:<h:form> <p:splitButton value="My Account" actionListener="#{selectionController.showAccount}" > <p:menuitem value="Change Password" url="changePwd.jsf" /> <p:menuitem value="Logout" ajax="false" actionListener="#{selectionController.logout}"/> </p:splitButton> </h:form>
What the just happened?
The preceding code displays SplitButton as shown in the following screenshot:
We have used <p:splitButton>
with default action My Account, which triggers the action listener method selectionController.showAccount()
. We have provided the other action items using <p:menuitem>
elements...