ContextMenu

compared with
Current by Arturo Zambrano
on Dec 11, 2014 03:42.


 
Key
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history


There are 3 changes. View first change.

 h2. Overview
 _Since 3.0_
  
 ContextMenu provides a popup menu that is displayed on mouse right-click event.
  
 {tip}See the ICEfaces Showcase [Live Demo|http://icefaces-showcase.icesoft.org/showcase.jsf?grp=aceMenu&exp=contextMenuBean] of this component, complete with source code.{tip}
  
 h2. Getting Started
 {panel}
 {code:xml|borderStyle=dashed}<h:outputText id="intro" value=" Right click on this sentence to display a component specific menu"/>
 ......
 <ace:contextMenu for="intro">
  <ace:menuItem value="Copy" icon="ui-icon ui-icon-disk" style="font-size: small;"
  action="#{contextMenuComponent.performAction}">
  <f:param name="actionType" value="Text Copy" />
  </ace:menuItem>
  <ace:menuItem value="Translate" icon="ui-icon ui-icon-arrowrefresh-1-w" style="font-style: small;"
  action="#{contextMenuComponent.performAction}">
  <f:param name="actionType" value="Text Translation" />
  </ace:menuItem>
 </ace:contextMenu>
 {code}
 {panel}
 h2. Attributes
  
 {tip:title=TagLib Documentation}This section covers attributes involved in the typical use-cases for this component. For reference, the complete taglib documentation for this component is available [here|http://www.icefaces.org/docs/v4_latest/ace/tld/ace/contextMenu.html].{tip}{panel}
 *for*: id of the component context menu is for.
 {panel}
 {panel}
 *effect* sets the effect for the menu display. Supports standard jQuery animations like "slide" and "fade".
 {panel}
 {panel}
 *effectDuration* sets the effect duration in milliseconds.
 {panel}
 h2. Event Listeners
  
 None.
  
 h2. Client Behavior Events
  
 None.
  
 h2. JavaScript API
  
 These components are based on The Wijmo Menu widget (see below for reference).
  h4. ICEfaces 3.x
  
The client side component object is exposed through the global variable name specified in the *widgetVar* attribute.
  
 h4. ICEfaces 4+
  
 The "widgetVar" attribute on the ACE components has been removed in ICEfaces 4 and in its place a new "ice.ace.instance()" client JavaScript object lookup API has been introduced. The reason for this change is to enable lazy-initialization of the ACE component JavaScript objects to improve runtime performance and reduce browser memory use.
  
 {code}var widget = ice.ace.instance('frm:componentId);{code}
  
 {tip}The _ice.ace.instance_ function requires the _full_ client id of the component to be specified, such as "j_idt77:componentId" instead of just "componentId". To reduce the complexity of working with complete IDs with this function it may be preferable in some cases to use {{prependId="false"}} in the enclosing form (e.g. _<h:form prependId="false">_).{tip}
  
 {info}This component doesn't have a client-side API made specifically to be used by application developers. However, the component's internal methods and variables can be accessed in this way, including the underlying jQuery object and objects from underlying Javascript libraries (if applicable), and can be used for whatever purpose a developer might have in mind.
 {info}
  
  
 h2. Keyboard and ARIA Support
  
 The following ARIA roles are supported: menu, menuitem.
  
 h2. CSS Classes
  
 The following markup represents the basic HTML structure of the component and the CSS classes it uses.
  
 {code:xml}
 <!-- Root container -->
 <span>
  <div class="ui-widget ui-widget-content wijmo-wijmenu ui-corner-all ui-helper-clearfix wijmo-wijmenu-flyout [user defined classes]" style="[user defined styles]">
  <div class="scrollcontainer checkablesupport">
  <ul class="wijmo-wijmenu-list ui-helper-reset">
  <!-- First level submenu item -->
  <li class="ui-widget wijmo-wijmenu-item ui-state-default ui-corner-all wijmo-wijmenu-parent">
  <a class="wijmo-wijmenu-link ui-corner-all">
  <span class="wijmo-wijmenu-text">
  <span class="ui-icon ui-icon-document wijmo-wijmenu-icon-left"></span>
  <span class="wijmo-wijmenu-text">First level submenu label</span>
  </span>
  <span class="ui-icon ui-icon-triangle-1-e"></span>
  </a>
  <ul class="wijmo-wijmenu-list ui-widget-content ui-corner-all ui-helper-clearfix wijmo-wijmenu-child wijmo-wijmenu-flyout">
  <!-- Second level submenu item -->
  <li class="ui-widget wijmo-wijmenu-item ui-state-default ui-corner-all">
  <a class="wijmo-wijmenu-link ui-corner-all">
  <span class="wijmo-wijmenu-text">
  <span class="ui-icon ui-icon-disk wijmo-wijmenu-icon-left"></span>
  <span class="wijmo-wijmenu-text">Second level submenu label</span>
  </span>
  </a>
  </li>
  </ul>
  </li>
  </ul>
  </div>
  </div>
 </span>
 {code}
  
 h2. Known Issues
  
 At the moment, specifying an effect does not work for IE 7 and IE 8, the default 'slide' effect will always be applied on such browsers.
  
 {panel}
 There's a known issue when using MyFaces and building menus from a model. If the bean where the model is created is using a scope different than @SessionScope and the menu is not recreated at every request (e.g. only created in the constructor), then MyFaces will hand in a corrupt model object with loss of information to the component code. Visually, this looks like the menu disappears at the first dynamic update. The problem is related to serialization in MyFaces.
 This situation can fixed by adding the following markup in the deployment descriptor:
 {code}
 <context-param>
  <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
  <param-value>false</param-value>
  </context-param>
 {code}
 Alternatively, if adding the above parameter is not possible. This problem can be avoided by simply using @SessionScope in the bean that creates the model object. If this is not possible either, another solution is to simply generate the model at every request (e.g. in the getter method for the model).
 {panel}
  
 {panel}
 There seems to be an issue when using a custom style class, not overriding certain styles defined by the current theme, even though the custom style class is added correctly at the end of the 'class' attribute of the root container. The way to fix this is by either forcing rule precedence by adding the '!important' keyword at the end of each rule in the custom class or by simply making the custom class more specific, in order to make it have more precedence. For example, instead of '.myClass', define the custom class as 'div.myClass'.
 {panel}
  
 {panel}
 Whenever a menu item is dynamically changed, without updating the entire menu in which it is, it may appear to lose some styling and behaviour. This is so, because the nodes corresponding to the menu item were replaced without re-initializing the whole menu on the client, which applies additional styling and behaviour. For these cases, simply set the {{forceMenuUpdate}} attribute to {{true}} in an event listener when the change in the menu item occurs, and the whole menu will be updated to keep all the necessary styling and bahaviour for the menu to work properly. This attribute will be automatically set back to false by the component after being consumed.
 {panel}
  
 h2. Other Notes
  
 {panel}
 This component can be used in delegate mode. For more information, visit this [page|http://www.icesoft.org/wiki/display/ICE/Delegate].
 {panel}
  
 h2. Additional Resources
 Wijmo Menu Documentation
 * [http://wijmo.com/wiki/index.php/Menu]
 * [http://wijmo.com/widgets/wijmo-open/menu/]

© Copyright 2018 ICEsoft Technologies Canada Corp.