コード例 #1
0
ファイル: RendererUtil.java プロジェクト: kojisano/teeda
 static Renderer getRenderer(final FacesContext context, final UIComponent component) {
   final String rendererType = component.getRendererType();
   if (rendererType == null) {
     return null;
   }
   final RenderKit renderKit = RenderKitUtil.getRenderKit(context);
   return renderKit.getRenderer(component.getFamily(), rendererType);
 }
コード例 #2
0
ファイル: ComponentUtils.java プロジェクト: shanmuka/icefaces
  public static String getWidgetVar(String id) {
    UIComponent component = findComponent(FacesContext.getCurrentInstance().getViewRoot(), id);
    Renderer renderer =
        FacesContext.getCurrentInstance()
            .getRenderKit()
            .getRenderer(component.getFamily(), component.getRendererType());

    if (component == null) throw new FacesException("Cannot find component " + id + " in view.");
    else if (!(renderer instanceof CoreRenderer))
      throw new FacesException("Component with id " + id + " is not derived from CoreRenderer.");

    return ((CoreRenderer) renderer).resolveWidgetVar(component);
  }
コード例 #3
0
 private static UIComponent findLabelFor(UIComponent root, String clientId) {
   for (UIComponent c : (List<UIComponent>) root.getChildren()) {
     if ("javax.faces.Label".equals(c.getRendererType())) {
       String labelFor = (String) c.getAttributes().get("for");
       if (clientId.equals(labelFor) || clientId.endsWith(":" + labelFor)) {
         return c;
       }
     }
     if (c.getChildCount() > 0) {
       // look for the right label recursively
       UIComponent label = findLabelFor(c, clientId);
       if (label != null) {
         return label;
       }
     }
   }
   return null;
 }