Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.richfaces.renderkit.html;
  
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import  javax.faces.application.ResourceDependencies;
 import  javax.faces.application.ResourceDependency;
 import  javax.faces.component.UIComponent;
 import  javax.faces.context.FacesContext;
 
 import  org.richfaces.component.Mode;
 import  org.richfaces.component.Positioning;
 
 @ResourceDependencies({ @ResourceDependency(library = "org.richfaces", name = "ajax.reslib"),
         @ResourceDependency(library = "org.richfaces", name = "base-component.reslib"),
         @ResourceDependency(name = "jquery.position.js"), @ResourceDependency(name = "richfaces-event.js"),
         @ResourceDependency(library = "org.richfaces", name = "popup.js"),
         @ResourceDependency(library = "org.richfaces", name = "menuKeyNavigation.js"),
         @ResourceDependency(library = "org.richfaces", name = "menu-base.js"),
         @ResourceDependency(library = "org.richfaces", name = "menu.js"),
         @ResourceDependency(library = "org.richfaces", name = "dropdownmenu.ecss", target = "head") })
 public abstract class DropDownMenuRendererBase extends RendererBase {
     public static final String RENDERER_TYPE = "org.richfaces.DropDownMenuRenderer";
     public static final int DEFAULT_MIN_POPUP_WIDTH = 250;
     public static final String DEFAULT_SHOWEVENT = "mouseover";
 
     @Override
     public void renderChildren(FacesContext facesContext, UIComponent componentthrows IOException {
         AbstractDropDownMenu dropDownMenu = (AbstractDropDownMenucomponent;
 
         for (UIComponent child : dropDownMenu.getChildren()) {
             if (child.isRendered()
                     && (child instanceof AbstractMenuGroup || child instanceof AbstractMenuItem || child instanceof AbstractMenuSeparator)) {
 
                 child.encodeAll(facesContext);
             }
         }
     }
 
     protected boolean isDisabled(FacesContext facesContext, UIComponent component) {
         if (component instanceof AbstractDropDownMenu) {
             return ((AbstractDropDownMenucomponent).isDisabled();
         }
         return false;
     }
 
     protected UIComponent getLabelFacet(FacesContext facesContext, UIComponent component) {
         UIComponent facet = null;
         AbstractDropDownMenu ddmenu = (AbstractDropDownMenucomponent;
         if (ddmenu != null) {
             facet = ddmenu.getFacet(...toString());
             if (!ddmenu.isDisabled() || facet == null) {
                 facet = ddmenu.getFacet(...toString());
             }
         }
         return facet;
     }
 
     public List<Map<StringObject>> getMenuGroups(FacesContext facesContext, UIComponent component) {
         List<Map<StringObject>> results = new ArrayList<Map<StringObject>>();
         List<AbstractMenuGroupgroups = new ArrayList<AbstractMenuGroup>();
         if (component instanceof AbstractDropDownMenu) {
             if (component.isRendered() && !((AbstractDropDownMenucomponent).isDisabled()) {
                 getMenuGroups(componentgroups);
             }
         }
         for (AbstractMenuGroup group : groups) {
             if (group.isRendered() && !group.isDisabled()) {
                 Map<StringObjectmap = new HashMap<StringObject>();
                 map.put("id"group.getClientId(facesContext));
                 RenderKitUtils.addToScriptHash(map"onhide"group.getOnhide(), null.);
                 RenderKitUtils.addToScriptHash(map"onshow"group.getOnshow(), null.);
                 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());
 
                RenderKitUtils.addToScriptHash(map"cssRoot"component.getAttributes().get("cssRoot"), "ddm");
                results.add(map);
            }
        }
        return results;
    }
    protected int getPopupWidth(UIComponent component) {
        int width = ((AbstractDropDownMenucomponent).getPopupWidth();
        if (width <= 0) {
            width = ;
        }
        return width;
    }
    protected Mode getMode(UIComponent component) {
        Mode mode = ((AbstractDropDownMenucomponent).getMode();
        if (mode == null) {
            mode = Mode.server;
        }
        return mode;
    }
    protected Positioning getJointPoint(UIComponent component) {
        Positioning jointPoint = ((AbstractDropDownMenucomponent).getJointPoint();
        if (jointPoint == null) {
            jointPoint = org.richfaces.component.Positioning.DEFAULT;
        }
        return jointPoint;
    }
    protected Positioning getDirection(UIComponent component) {
        Positioning direction = ((AbstractDropDownMenucomponent).getDirection();
        if (direction == null) {
            direction = org.richfaces.component.Positioning.DEFAULT;
        }
        return direction;
    }
    private void getMenuGroups(UIComponent componentList<AbstractMenuGrouplist) {
        if (component != null && list != null) {
            for (UIComponent c : component.getChildren()) {
                if (c instanceof AbstractMenuGroup) {
                    list.add((AbstractMenuGroupc);
                }
                getMenuGroups(clist);
            }
        }
    }
    protected String getShowEvent(UIComponent component) {
        String value = ((AbstractDropDownMenucomponent).getShowEvent();
        if (value == null || "".equals(value)) {
            value = ;
        }
        return value;
    }
New to GrepCode? Check out our FAQ X