@ManagedBean @SessionScoped public class TooltipBean implements Serializable { /** */ private static final long serialVersionUID = -2860886265782541618L; private int tooltipCounter = 0; private Positioning jointPoint = Positioning.DEFAULT; private Positioning direction = Positioning.DEFAULT; private int horizontalOffset = 0; private int verticalOffset = 0; private Positioning[] positioningValues = Positioning.values(); public int getTooltipCounter() { return tooltipCounter++; } public Date getTooltipDate() { return new Date(); } public void setJointPoint(Positioning jointPoint) { this.jointPoint = jointPoint; } public Positioning getJointPoint() { return jointPoint; } public void setDirection(Positioning direction) { this.direction = direction; } public Positioning getDirection() { return direction; } public void setHorizontalOffset(int horizontalOffset) { this.horizontalOffset = horizontalOffset; } public int getHorizontalOffset() { return horizontalOffset; } public void setVerticalOffset(int verticalOffset) { this.verticalOffset = verticalOffset; } public int getVerticalOffset() { return verticalOffset; } public Positioning[] getPositioningValues() { return positioningValues; } }
public List<Map<String, Object>> getMenuGroups(FacesContext facesContext, UIComponent component) { List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); List<AbstractMenuGroup> groups = new ArrayList<AbstractMenuGroup>(); if (component instanceof AbstractDropDownMenu) { if (component.isRendered() && !((AbstractDropDownMenu) component).isDisabled()) { getMenuGroups(component, groups); } } for (AbstractMenuGroup group : groups) { if (group.isRendered() && !group.isDisabled()) { Map<String, Object> map = new HashMap<String, Object>(); map.put("id", group.getClientId(facesContext)); RenderKitUtils.addToScriptHash( map, "onhide", group.getOnhide(), null, ScriptHashVariableWrapper.eventHandler); RenderKitUtils.addToScriptHash( map, "onshow", group.getOnshow(), null, ScriptHashVariableWrapper.eventHandler); RenderKitUtils.addToScriptHash(map, "verticalOffset", group.getVerticalOffset(), "0"); RenderKitUtils.addToScriptHash(map, "horizontalOffset", group.getHorizontalOffset(), "0"); Positioning jointPoint = group.getJointPoint(); if (jointPoint == null) { jointPoint = org.richfaces.component.Positioning.DEFAULT; } RenderKitUtils.addToScriptHash( map, "jointPoint", jointPoint.getValue(), org.richfaces.component.Positioning.DEFAULT.getValue()); Positioning direction = group.getDirection(); if (direction == null) { direction = org.richfaces.component.Positioning.DEFAULT; } RenderKitUtils.addToScriptHash( map, "direction", direction.getValue(), org.richfaces.component.Positioning.DEFAULT.getValue()); results.add(map); } } return results; }
@Override protected Map<String, Object> getScriptObjectOptions( FacesContext context, UIComponent component) { AbstractTooltip tooltip = (AbstractTooltip) component; Map<String, Object> options = new HashMap<String, Object>(); RenderKitUtils.addToScriptHash( options, "ajax", getAjaxOptions(context, tooltip), TooltipMode.DEFAULT); Positioning jointPoint = tooltip.getJointPoint(); if (jointPoint == null) { jointPoint = org.richfaces.component.Positioning.DEFAULT; } Positioning direction = tooltip.getDirection(); if (direction == null) { direction = org.richfaces.component.Positioning.DEFAULT; } RenderKitUtils.addToScriptHash( options, "jointPoint", jointPoint.getValue(), Positioning.DEFAULT.getValue()); RenderKitUtils.addToScriptHash( options, "direction", direction.getValue(), Positioning.DEFAULT.getValue()); RenderKitUtils.addToScriptHash(options, "attached", tooltip.isAttached(), true); RenderKitUtils.addToScriptHash(options, "offset", getOffset(tooltip)); RenderKitUtils.addToScriptHash(options, "mode", tooltip.getMode(), TooltipMode.DEFAULT); RenderKitUtils.addToScriptHash(options, "hideDelay", tooltip.getHideDelay(), 0); RenderKitUtils.addToScriptHash(options, "hideEvent", tooltip.getHideEvent(), "mouseleave"); RenderKitUtils.addToScriptHash(options, "showDelay", tooltip.getShowDelay(), 0); RenderKitUtils.addToScriptHash(options, "showEvent", tooltip.getShowEvent(), "mouseenter"); RenderKitUtils.addToScriptHash(options, "followMouse", tooltip.isFollowMouse(), true); RenderKitUtils.addToScriptHash( options, "target", RENDERER_UTILS.findComponentFor(component, tooltip.getTarget()).getClientId(context)); addEventOption(context, tooltip, options, HIDE); addEventOption(context, tooltip, options, SHOW); addEventOption(context, tooltip, options, BEFORE_HIDE); addEventOption(context, tooltip, options, BEFORE_SHOW); return options; }