Java Code Examples for javax.faces.component.UIComponent.getFamily()

The following are Jave code examples for showing how to use getFamily() of the javax.faces.component.UIComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: myfaces-trinidad   File: LabelAndMessageRenderer.java   Source Code and License Vote up 6 votes
private boolean _needsTableTag(
  UIComponent component)
{
  // Find the first content-generating parent
  UIComponent parent = XhtmlUtils.getStructuralParent(component);
  if (parent == null)
    return true;

  // =-=AEW We should review this code.
  // Either the parent should mark down that it rendered
  // a table, or we should lean on the ResponseWriter
  // to tell us if a table had been used.

  // Hardcoding some packages 'cause I need this code to change!
  String family = parent.getFamily();
  if (HtmlTableLayout.COMPONENT_FAMILY.equals(family))
  {
    return false;
  }

  return true;
}
 
Example 2
Project: myfaces-trinidad   File: DebugResponseWriter.java   Source Code and License Vote up 6 votes
@Override
public void startElement(String name, UIComponent component) throws IOException
 {
   if ((component != null) && (_lastComponentStarted != component))
   {
     String componentAsString = component.getFamily();
     String id = component.getId();
     if (id != null)
     {
       componentAsString = componentAsString + "[\"" + id + "\"]";
     }

     writeComment("Start: " + componentAsString);

     _lastComponentStarted = component;
   }

   super.startElement(name, component);
   _inElement = true;
   _elementStack.push(name);
   _attributes.clear();
 }
 
Example 3
Project: myfaces-trinidad   File: RenderUtils.java   Source Code and License Vote up 6 votes
/**
 * Returns the clientId used by the renderer in place of the clientId used by the component.
 * Certain renderers render their root element with a clientId that differs from the one
 * used by the component.
 * @param context FacesContent.
 * @param component UIComponent.
 * @return component clientId if the renderer clientId is null. Otherwise clientId used by 
 * renderer.
 */
public static String getRendererClientId(
  FacesContext context, 
  UIComponent component) 
{
  String clientId = component.getClientId(context);
  String family = component.getFamily();
  String rendererType = component.getRendererType();
  if (rendererType != null)
  {
    Renderer renderer = context.getRenderKit().getRenderer(family, rendererType);
    if (renderer instanceof CoreRenderer)
    {
      CoreRenderer coreRenderer = (CoreRenderer) renderer;
      String rendererClientId = coreRenderer.getClientId(context, component);
      return rendererClientId == null ? clientId : rendererClientId;
    }
  }
  return clientId;
}
 
Example 4
Project: myfaces-trinidad   File: PanelFormLayoutRenderer.java   Source Code and License Vote up 5 votes
/**
 * Helper method to return a <code>Renderer</code> instance for a given <code>UIComponent</code>
 * object.
 * @param context the <code>FacesContext</code> for the request we currently processing
 * @param component the child component
 * @return <code>Renderer</code> for the given <code>UIComponent</code>.
 */
private Renderer _getRenderer(
  FacesContext context,
  UIComponent  component)
{
  // =-= AEW Might consider altering the following approach of getting the
  //         child renderer in case anyone wants to use renderer decoration.
  String family = component.getFamily();
  String rendererType = component.getRendererType();
  if (rendererType == null)
    return null;
  else
    return context.getRenderKit().getRenderer(family, rendererType);
}
 
Example 5
Project: myfaces-trinidad   File: LabelAndMessageRenderer.java   Source Code and License Vote up 5 votes
private boolean _isParentPanelForm(
  FacesContext context,
  UIComponent  component)
{
  if (PanelFormLayoutRenderer.__isInPanelFormLayout(context, component))
  {
    return true;
  }

  // We must know if the immediate parent is a PanelForm because if there is
  // even just one other component inbetween this component and a PanelForm,
  // we must render different DOM--the same DOM as if there were no parent
  // PanelForm.
  UIComponent parentComponent = component.getParent();
  String family = parentComponent.getFamily();
  // FIXME: OK... This is another strong coupling
  //        We could add a an interface instead like ComponentHolder or something
  //        instead of checking against a specific component family.
  while (UIXGroup.COMPONENT_FAMILY.equals(family))
  {
    // Special case:
    // Since UIXGroup components are purely organizational, it is valid to
    // have them inbetween panelForm-friendly components and the panelForm,
    // so we need to look further up the chain:
    parentComponent = parentComponent.getParent();
    if (parentComponent == null)
    {
      return false;
    }
    family = parentComponent.getFamily();
  }
  if (UIXPanel.COMPONENT_FAMILY.equals(family))
  {
    String rendererType = parentComponent.getRendererType();
    if (_isFormRendererType(rendererType))
      return true;
  }
  return false;
}