The menuButton component will be stateless to the end user and will allow for a form to be submitted when a selection has occurred or an optional single submit; but both submit methods would execute the selected option element's action listener in the invoke application phase of the JSF lifecycle. The component will have now value change event that is publicly accessible by the JSF application developer.
A typeical usage from a JSF app developers point of view would be as follows notice both the action and actionListener events:
<mobi:menuButton buttonLabel="Actions Menu" styleClass="" style=""
itemTitleLabel="Actions" >
<mobi:menuButtonItem action="#
{someBean.navigationRule}
"
actionListener="#
{someBean.createRecord}">
Delete Record</mobi:menuButtonItem>
<mobi:menuButtonItem action="#{someBean.deleteRecord}">
Submit Record</mobi:menuButtonItem>
<mobi:menuButtonItem actionListener="#{someBean.createRecord}
">
Create Record</mobi:menuButtonItem>
<mobi:menuButtonItem actionListener="#
{someBean.updateRecord}
">
Update Record</mobi:menuButtonItem>
<mobi:menuButtonItem actionListener="#{someBean.deleteAll">
Delete All</mobi:menuButtonItem>
</mobi:menuButton>
The renderer output for the component will look something like this:
<div class="mobi-menu-btn ">
<span class="mobi-menu-btn-btn"><span>Actions Menu</span</span>
<select id="j_idt76" class="mobi-menu-btn-menu"
onchange="assignSelected(this);uncheckAll(this);submit(this)">
<option value="j_idt77">Actions</option>
<option value="j_idt81"> Delete Record</option>
<option value="j_idt83"> Submit Record</option>
<option value="j_idt85"> Create Record</option>
<option value="j_idt87"> Update Record</option>
<option value="j_idt89"> Delete All</option>
</select>
<input type="hidden" id="buttonValue" name="buttonValue" />
</div>
For the select component to behave correctly as a button a dummy option element must be inserted as the first record as it is the default selected item and will not generate a onchange event. When any other option is selected the hidden field is updated with the selected value and the selected state of the select element is cleared. Once the hidden field has been updated the form can be submitted, or the button single submitted if configured.
During the menuButton decode the component can match the submitted "selected" hidden value against it's own internal list of actions and actionListeners and queue up the necessary events to fire in the correct JSF phase. The component is stateless and should not echo the hidden field value back in the request.
Creation of a menuButton component that presents users with a list of menuItems that can be selected for execution. The general structure of the component would be as follows:
{mybean.command1}<mobi:menuButton label="Actions Menu" >
<mobi:menuItem label="command 1" actionListener="#
"/>
{mybean.command2}<mobi:menuItem label="command 2" actionListener="#
"/>
</mobi:menuButton>
The menuButton can be built statically as shown or dynamically when combined with the <ui:repeat/> tag. The component takes advantage of the HTML select element for presenting the user with a list of possible actions to select. Once an action is selected the list is hidden and the associated action is executed.
Assumptions