com.sun.webui.jsf.component
Class Menu

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by com.sun.webui.jsf.component.EventSourceImpl
              extended by com.sun.webui.jsf.component.Menu
All Implemented Interfaces:
EventSource, javax.faces.component.StateHolder

public class Menu
extends EventSourceImpl

 This class represents a Menu component.
 The class inherits from the com.sun.webui.jsf.component.WebUIInput
 and implements javax.faces.component.ActionSource2.. Hence, this component
 acts both as an editableValueHolder and an ActionSource. 
 
 A Menu contains a list of selectable options.
 The options to be displayed can be specified using the "items" attribute of the component.
 Each option should be represented by a com.sun.webui.jsf.model.Option instance.
 Options can also be grouped together based on some common functionality in which case, the 
 com.sun.webui.jsf.model.OptionGroup should be used for specifying the options.
 
 The menu will not be visible by default, but can be shown by calling the open
 method on the popupMenu widget when any of the components on the page is clicked. This method takes
 an event attribute as an argument. This "event" attribute is the event that is generated when some
 keyboard or mouse action  happens on the web page such as the "click" of a hyperlink. In this case,
 if the style attribtute with menu positioning is defined, the popupMenu widget will use that to
 position itself on the page. If not, it will use the event attribute which is passed on as argument
 to the popupMenu to position itself on the page.
 
 Whenever an option is clicked, you can access the selected option through the getSelectedOption interface
 available on the menu's dom element. This is the default behavior of the menu element.
 The default behavior does not have any form of communcation with the server to inform of the selected state.
 If a communication needs to be made to the server to inform of the selected value of the menu component
 then 
 
 i) Use domNode.submit() :- The menu element has a submit() function set on its dom. Invoking this function
    will cause the menu widget to send an asynchronous request to the server and cause the menu component
    to update itself. The menu widget in this case, appends an attribute called value to the dynamic faces
    request made. The com.sun.webui.jsf.renderkit.ajax.MenuRenderer will in this case look for 
    this particular value and update itself accordingly.
 
 ii) Set the submitForm attribute to true:- This will cause the menu component to submit the form whenever an
    option is selected in the menu. All the elements in the form will be submitted and all the components present
    in the form will go through the normal JSF processing lifecycle. 
    The Menu widget in this case will submit the value of the selected option similar to the way the hyperlink widget
    submits the form. It will append the selected value as a request parameter with the key being the client id of 
    the menu appended with a "_submittedValue" suffix.
 
 NOTE:- 
  To obtain the value of the option that was clicked in the menu widget, use the eventListenerExpression attribute
  and invoke the getSelectedOption method on the ValueEvent object that is passed as an argument to this method binding
 


Constructor Summary
Menu()
          Creates a new instance of Menu The constructor also sets the appropriate renderer type and instantiates the valueTypeEvaluator.
 
Method Summary
 java.lang.String getFamily()
          Return the family this component belongs to.
 java.lang.String getHtmlTemplate()
          Get alternative HTML template to be used by this component.
 java.lang.Object getItems()
          Specifies the items that the web application user can choose from.
 java.lang.String getOnChange()
          Scripting code executed when the element value of this component is changed.
 java.lang.String getOnClick()
          Scripting code executed when a mouse click occurs over this component.The popupMenu element has a function called getSelectedOption which can be invoked by onClick function handlers to know which option has been selected.
 java.lang.String getOnDblClick()
          Scripting code executed when a mouse double click occurs over this component.
 java.lang.String getOnKeyDown()
          Scripting code executed when the user presses down on a key while the component has focus.
 java.lang.String getOnKeyPress()
          Scripting code executed when the user presses and releases a key while the component has focus.
 java.lang.String getOnKeyUp()
          Scripting code executed when the user releases a key while the component has focus.
 java.lang.String getOnMouseDown()
          Scripting code executed when the user presses a mouse button while the mouse pointer is on the component.
 java.lang.String getOnMouseMove()
          Scripting code executed when the user moves the mouse pointer while over the component.
 java.lang.String getOnMouseOut()
          Scripting code executed when a mouse out movement occurs over this component.
 java.lang.String getOnMouseOver()
          Scripting code executed when the user moves the mouse pointer into the boundary of this component.
 java.lang.String getOnMouseUp()
          Scripting code executed when the user releases a mouse button while the mouse pointer is on the component.
 Option[] getOptionsArray()
          Processes the component's SelectItems.
 java.lang.String getRendererType()
          Return the appropriate renderer type.
 java.lang.String getStyle()
          CSS style or styles to be applied to the outermost HTML element when this component is rendered.
 java.lang.String getStyleClass()
          CSS style class or classes to be applied to the outermost HTML element when this component is rendered.
 boolean isSubmitForm()
          When set to true, the form is immediately submitted when the user changes the selection in the menu.
 boolean isVisible()
          Use to indicate whether the component should be viewable by the user in the rendered HTML page.
 void processDecodes(javax.faces.context.FacesContext context)
          Specialized decode behavior on top of that provided by the superclass.
 void restoreState(javax.faces.context.FacesContext _context, java.lang.Object _state)
           
 java.lang.Object saveState(javax.faces.context.FacesContext _context)
          Save the state of this component.
 void setHtmlTemplate(java.lang.String htmlTemplate)
          Set alternative HTML template to be used by this component.
 void setId(java.lang.String id)
          The component identifier for this component.
 void setItems(java.lang.Object items)
          Specifies the items that the web application user can choose from.
 void setOnChange(java.lang.String onChange)
          Scripting code executed when the user releases a mouse button while the mouse pointer is on the component.
 void setOnClick(java.lang.String onClick)
          Scripting code executed when a mouse click occurs over this component.The Menu element has a function called getSelectedOption which can be invoked by onClick function handlers to know which option has been selected.
 void setOnDblClick(java.lang.String onDblClick)
          Scripting code executed when a mouse double click occurs over this component.
 void setOnKeyDown(java.lang.String onKeyDown)
          Scripting code executed when the user presses down on a key while the component has focus.
 void setOnKeyPress(java.lang.String onKeyPress)
          Scripting code executed when the user presses and releases a key while the component has focus.
 void setOnKeyUp(java.lang.String onKeyUp)
          Scripting code executed when the user releases a key while the component has focus.
 void setOnMouseDown(java.lang.String onMouseDown)
          Scripting code executed when the user presses a mouse button while the mouse pointer is on the component.
 void setOnMouseMove(java.lang.String onMouseMove)
          Scripting code executed when the user moves the mouse pointer while over the component.
 void setOnMouseOut(java.lang.String onMouseOut)
          Scripting code executed when a mouse out movement occurs over this component.
 void setOnMouseOver(java.lang.String onMouseOver)
          Scripting code executed when the user moves the mouse pointer into the boundary of this component.
 void setOnMouseUp(java.lang.String onMouseUp)
          Scripting code executed when the user releases a mouse button while the mouse pointer is on the component.
 void setRendered(boolean rendered)
          Use the rendered attribute to indicate whether the HTML code for the component should be included in the rendered HTML page.
 void setStyle(java.lang.String style)
          CSS style or styles to be applied to the outermost HTML element when this component is rendered.
 void setStyleClass(java.lang.String styleClass)
          CSS style class or classes to be applied to the outermost HTML element when this component is rendered.
 void setSubmitForm(boolean submitForm)
          When set to true, the form is immediately submitted when the user changes the selection in the menu.
 void setVisible(boolean visible)
          Use to indicate whether the component should be viewable by the user in the rendered HTML page.
 
Methods inherited from class com.sun.webui.jsf.component.EventSourceImpl
addEventListener, broadcast, getEventExpression, getEventListenerExpression, getEventListeners, getPhaseId, isImmediate, processEventExpression, queueEvent, removeEventListener, setEventExpression, setEventListenerExpression, setImmediate, setPhaseId
 
Methods inherited from class javax.faces.component.UIComponentBase
decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRendersChildren, getValueBinding, getValueExpression, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, processUpdates, processValidators, restoreAttachedState, saveAttachedState, setParent, setRendererType, setTransient, setValueBinding, setValueExpression
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Menu

public Menu()
Creates a new instance of Menu The constructor also sets the appropriate renderer type and instantiates the valueTypeEvaluator.

Method Detail

getFamily

public java.lang.String getFamily()
Return the family this component belongs to. This method returns "com.sun.webui.jsf.Menu".

Specified by:
getFamily in class javax.faces.component.UIComponent

getRendererType

public java.lang.String getRendererType()
Return the appropriate renderer type. It returns the widget renderer if the request is a normal request and returns the ajax renderer if the request is a partial request.

Overrides:
getRendererType in class javax.faces.component.UIComponentBase

setId

public void setId(java.lang.String id)
The component identifier for this component. This value must be unique within the closest parent component that is a naming container.

Overrides:
setId in class javax.faces.component.UIComponentBase

setRendered

public void setRendered(boolean rendered)
Use the rendered attribute to indicate whether the HTML code for the component should be included in the rendered HTML page. If set to false, the rendered HTML page does not include the HTML for the component. If the component is not rendered, it is also not processed on any subsequent form submission.

Overrides:
setRendered in class javax.faces.component.UIComponentBase

getHtmlTemplate

public java.lang.String getHtmlTemplate()

Get alternative HTML template to be used by this component.


setHtmlTemplate

public void setHtmlTemplate(java.lang.String htmlTemplate)

Set alternative HTML template to be used by this component.


getStyle

public java.lang.String getStyle()

CSS style or styles to be applied to the outermost HTML element when this component is rendered.


setStyle

public void setStyle(java.lang.String style)

CSS style or styles to be applied to the outermost HTML element when this component is rendered.

See Also:
getStyle()

getStyleClass

public java.lang.String getStyleClass()

CSS style class or classes to be applied to the outermost HTML element when this component is rendered.


setStyleClass

public void setStyleClass(java.lang.String styleClass)

CSS style class or classes to be applied to the outermost HTML element when this component is rendered.

See Also:
getStyleClass()

isVisible

public boolean isVisible()

Use to indicate whether the component should be viewable by the user in the rendered HTML page. If set to false, the HTML code for the component is present in the page, but the component is hidden with style attributes. By default,this setting is false, so HTML for the component HTML is rendered but the menu is not visible to user. Note that, even If the component is not visible, it can still be processed on subsequent form submissions because the HTML is present.


setVisible

public void setVisible(boolean visible)

Use to indicate whether the component should be viewable by the user in the rendered HTML page. If set to false, the HTML code for the component is present in the page, but the component is hidden with style attributes. By default,this setting is false, so HTML for the component HTML is rendered but the menu is not visible to user. Note that, even If the component is not visible, it can still be processed on subsequent form submissions because the HTML is present.

See Also:
isVisible()

getOnClick

public java.lang.String getOnClick()

Scripting code executed when a mouse click occurs over this component.The popupMenu element has a function called getSelectedOption which can be invoked by onClick function handlers to know which option has been selected. This will return the name of the option that was clicked.


setOnClick

public void setOnClick(java.lang.String onClick)

Scripting code executed when a mouse click occurs over this component.The Menu element has a function called getSelectedOption which can be invoked by onClick function handlers to know which option has been selected. This will return the name of the option that was clicked.

See Also:
getOnClick()

getOnDblClick

public java.lang.String getOnDblClick()

Scripting code executed when a mouse double click occurs over this component.


setOnDblClick

public void setOnDblClick(java.lang.String onDblClick)

Scripting code executed when a mouse double click occurs over this component.

See Also:
getOnDblClick()

getOnKeyDown

public java.lang.String getOnKeyDown()

Scripting code executed when the user presses down on a key while the component has focus.


setOnKeyDown

public void setOnKeyDown(java.lang.String onKeyDown)

Scripting code executed when the user presses down on a key while the component has focus.

See Also:
getOnKeyDown()

getOnKeyPress

public java.lang.String getOnKeyPress()

Scripting code executed when the user presses and releases a key while the component has focus.


setOnKeyPress

public void setOnKeyPress(java.lang.String onKeyPress)

Scripting code executed when the user presses and releases a key while the component has focus.

See Also:
getOnKeyPress()

getOnKeyUp

public java.lang.String getOnKeyUp()

Scripting code executed when the user releases a key while the component has focus.


setOnKeyUp

public void setOnKeyUp(java.lang.String onKeyUp)

Scripting code executed when the user releases a key while the component has focus.

See Also:
getOnKeyUp()

getOnMouseDown

public java.lang.String getOnMouseDown()

Scripting code executed when the user presses a mouse button while the mouse pointer is on the component.


setOnMouseDown

public void setOnMouseDown(java.lang.String onMouseDown)

Scripting code executed when the user presses a mouse button while the mouse pointer is on the component.

See Also:
getOnMouseDown()

getOnMouseMove

public java.lang.String getOnMouseMove()

Scripting code executed when the user moves the mouse pointer while over the component.


setOnMouseMove

public void setOnMouseMove(java.lang.String onMouseMove)

Scripting code executed when the user moves the mouse pointer while over the component.

See Also:
getOnMouseMove()

getOnMouseOut

public java.lang.String getOnMouseOut()

Scripting code executed when a mouse out movement occurs over this component.


setOnMouseOut

public void setOnMouseOut(java.lang.String onMouseOut)

Scripting code executed when a mouse out movement occurs over this component.

See Also:
getOnMouseOut()

getOnMouseOver

public java.lang.String getOnMouseOver()

Scripting code executed when the user moves the mouse pointer into the boundary of this component.


setOnMouseOver

public void setOnMouseOver(java.lang.String onMouseOver)

Scripting code executed when the user moves the mouse pointer into the boundary of this component.

See Also:
getOnMouseOver()

getOnMouseUp

public java.lang.String getOnMouseUp()

Scripting code executed when the user releases a mouse button while the mouse pointer is on the component.


setOnMouseUp

public void setOnMouseUp(java.lang.String onMouseUp)

Scripting code executed when the user releases a mouse button while the mouse pointer is on the component.

See Also:
getOnMouseUp()

getItems

public java.lang.Object getItems()

Specifies the items that the web application user can choose from. The value must be one of an array, Map or Collection whose members are all subclasses ofcom.sun.webui.jsf.model.Option.


setItems

public void setItems(java.lang.Object items)

Specifies the items that the web application user can choose from. The value must be one of an array, Map or Collection whose members are all subclasses ofcom.sun.webui.jsf.model.Option.

See Also:
getItems()

getOnChange

public java.lang.String getOnChange()

Scripting code executed when the element value of this component is changed.


setOnChange

public void setOnChange(java.lang.String onChange)

Scripting code executed when the user releases a mouse button while the mouse pointer is on the component.

See Also:
getOnMouseUp()

isSubmitForm

public boolean isSubmitForm()

When set to true, the form is immediately submitted when the user changes the selection in the menu.


setSubmitForm

public void setSubmitForm(boolean submitForm)

When set to true, the form is immediately submitted when the user changes the selection in the menu.


processDecodes

public void processDecodes(javax.faces.context.FacesContext context)

Specialized decode behavior on top of that provided by the superclass.

Overrides:
processDecodes in class javax.faces.component.UIComponentBase
Parameters:
context - FacesContext for this request.

getOptionsArray

public Option[] getOptionsArray()
Processes the component's SelectItems. Constructs an ArrayList of Options.


restoreState

public void restoreState(javax.faces.context.FacesContext _context,
                         java.lang.Object _state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class EventSourceImpl

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext _context)

Save the state of this component.

Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class EventSourceImpl


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.