Java Code Examples for javax.faces.component.UIComponent#getChildren()

The following examples show how to use javax.faces.component.UIComponent#getChildren() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSFUtils.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * Reset the values of all UIInput children. This might be necessary after a
 * validation error to successfully process an AJAX request. See [Bug 5449]
 * and http://wiki.apache.org/myfaces/ClearInputComponents
 * 
 * @param uiComponent
 *            the root component to be processed.
 */
public static void resetUIInputChildren(UIComponent uiComponent) {
    if (uiComponent != null) {
        List<UIComponent> children = uiComponent.getChildren();
        for (UIComponent child : children) {
            if (child instanceof UIInput) {
                UIInput uiInput = (UIInput) child;
                uiInput.setSubmittedValue(null);
                uiInput.setValue(null);
                uiInput.setLocalValueSet(false);
            } else {
                resetUIInputChildren(child);
            }
        }
    }
}
 
Example 2
Source File: AJAXRenderer.java    From BootsFaces-OSP with Apache License 2.0 6 votes vote down vote up
private static void encodeFormSubmit(UIComponent component, ResponseWriter rw, boolean evenWithoutParameters)
		throws IOException {
	String parameterList = "";
	List<UIComponent> children = component.getChildren();
	for (UIComponent parameter : children) {
		if (parameter instanceof UIParameter) {
			String value = String.valueOf(((UIParameter) parameter).getValue());
			String name = ((UIParameter) parameter).getName();
			if (null != value) {
				parameterList += ",'" + name + "':'" + value + "'";
			}
		}
	}
	if (evenWithoutParameters || parameterList.length() > 0) {
		UIForm currentForm = getSurroundingForm((UIComponent) component, false);
		parameterList = "'" + currentForm.getClientId() + "',{'" + component.getClientId() + "':'"
				+ component.getClientId() + "'" + parameterList + "}";
		rw.writeAttribute("onclick",
				encodeClick((UIComponent) component) + "BsF.submitForm(" + parameterList + ");return false;", null);
	}
}
 
Example 3
Source File: R.java    From BootsFaces-OSP with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a CSS class to a component within a facet.
 * 
 * @param f
 *            the facet
 * @param cname
 *            the class name of the component to be manipulated.
 * @param aclass
 *            the CSS class to be added
 */
public static void addClass2FacetComponent(UIComponent f, String cname, String aclass) {
	// If the facet contains only one component, getChildCount()=0 and the
	// Facet is the UIComponent
	if (f.getClass().getName().endsWith(cname)) {
		addClass2Component(f, aclass);
	} else {
		if (f.getChildCount() > 0) {
			for (UIComponent c : f.getChildren()) {
				if (c.getClass().getName().endsWith(cname)) {
					addClass2Component(c, aclass);
				}
			}
		}
	}
}
 
Example 4
Source File: DialogRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public void encodeButtonBar(FacesContext context, UIComponent component) throws IOException {
    @SuppressWarnings("unchecked") // $NON-NLS-1$
    List<UIComponent> children = component.getChildren();
    for (UIComponent c : children) {
        if (c instanceof UIDialogButtonBar) {
            ResponseWriter w = context.getResponseWriter();
            w.startElement("div", component); // $NON-NLS-1$
            w.writeAttribute("class", "modal-footer", null); // $NON-NLS-1$ $NON-NLS-2$
                                                                // $NON-NLS-2$
            FacesUtil.renderComponent(context, c);
            w.endElement("div"); // $NON-NLS-1$
        }
    }
}
 
Example 5
Source File: AbstractApplicationLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void renderChildren(FacesContext context, UIComponent component) throws IOException {
    // encode component and children
    int count = component.getChildCount();
    if(count>0) {
        List<?> children = component.getChildren();
        for (int i=0; i<count; i++) {
            UIComponent child = (UIComponent)children.get(i);
            if(isRenderChild(context, child)) {
                FacesUtil.renderComponent(context, child);  
            }
        }
    }
}
 
Example 6
Source File: ResponsiveAppLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void renderChildren(FacesContext context, UIComponent component) throws IOException {
    // encode component and children
    int count = component.getChildCount();
    if (count > 0) {
        List<?> children = component.getChildren();
        for (int i = 0; i < count; i++) {
            UIComponent child = (UIComponent) children.get(i);
            if (isRenderChild(context, child)) {
                FacesUtil.renderComponent(context, child);
            }
        }
    }
}
 
Example 7
Source File: TabRenderer.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
@Override
public void decode(FacesContext context, UIComponent component) {
	// The AJAXRenderer generates the id of the child element, but the AJAX event is processed by the parent instead
	component.getParent().decode(context);
	for (UIComponent c: component.getChildren()) {
		c.decode(context);
	}
}
 
Example 8
Source File: DynFormFactory.java    From yawl with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addSubPanel(SubPanel panel) {
    SubPanel newPanel = new SubPanelCloner().clone(panel, this, createUniqueID("clone"));

    // get container of this panel
    UIComponent parent = panel.getParent();
    List children = parent.getChildren();

    // insert the new panel directly after the cloned one
    children.add(children.indexOf(panel) + 1, newPanel);

    SubPanel level0Container = panel.getController().addSubPanel(newPanel);
    int adjustment = (int) newPanel.getHeight() + DynFormFactory.Y_DEF_INCREMENT;
    adjustLayouts(level0Container, adjustment);
}
 
Example 9
Source File: AudioUploadActionListener.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Get audio media upload path from the event's component tree.
 * @param ae  the event
 * @return
 */
private String getAudioMediaUploadPath(FacesEvent ae)
{
  String audioMediaUploadPath = null;

  // now find what component fired the event
  UIComponent component = ae.getComponent();
  // get the subview containing the audio question
  UIComponent parent = component.getParent();

  // get the its peer components from the parent
  List peers = parent.getChildren();

  // look for the correct file upload path information
  // held in the value of the component 'audioMediaUploadPath'
  for (int i = 0; i < peers.size(); i++)
  {
    UIComponent peer = (UIComponent) peers.get(i);

    if ("audioMediaUploadPath".equals(peer.getId()) && peer instanceof UIOutput)
    {
      audioMediaUploadPath = "" + ((UIOutput) peer).getValue();
      log.info("FOUND: Component " + i +
               " peer.getId(): " + peer.getId()+
               " peer.getValue(): " + audioMediaUploadPath );
      break;
    }
  }

  return audioMediaUploadPath;
}
 
Example 10
Source File: DialogRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public void encodeContent(FacesContext context, UIComponent component) throws IOException {
    @SuppressWarnings("unchecked") // $NON-NLS-1$
    List<UIComponent> children = component.getChildren();
    for (UIComponent c : children) {
        if (c instanceof UIDialogContent) {
            ResponseWriter w = context.getResponseWriter();
            w.startElement("div", component); // $NON-NLS-1$
            w.writeAttribute("class", "modal-body", null); // $NON-NLS-1$ $NON-NLS-2$
                                                            // $NON-NLS-2$
            FacesUtil.renderComponent(context, c);
            w.endElement("div"); // $NON-NLS-1$
        }
    }
}
 
Example 11
Source File: HideDivisionRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void encodeBegin(FacesContext context, UIComponent component)
throws IOException {

  if (!component.isRendered()) {
    return;
  }

  ResponseWriter writer = context.getResponseWriter();
  String jsfId = (String) RendererUtil.getAttribute(context, component, "id");
  String id = jsfId;

  if (component.getId() != null &&
      !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
  {
    id = component.getClientId(context);
  }

  String title = (String) RendererUtil.getAttribute(context, component, "title");
  Object tmpFoldStr = RendererUtil.getAttribute(context, component, "hideByDefault");
  boolean foldDiv = tmpFoldStr != null && "true".equals(tmpFoldStr);
  String foldImage = foldDiv ? FOLD_IMG_HIDE : FOLD_IMG_SHOW;
  writer.write("<" + BARTAG + " class=\"" + BARSTYLE + "\">");
  writer.write("<table style=\"width: 100%;\" class=\"discTria\" cellpadding=\"0\" cellspacing=\"0\" >");
  writer.write("<tr><td  class=\"discTria\" onclick=\"javascript:showHideDivBlock('" + id +
      "', '" +  RESOURCE_PATH + "');\">" );
  writer.write("  <img id=\"" + id + "__img_hide_division_" + "\" alt=\"" +
      title + "\"");
  writer.write("    src=\""   + foldImage + "\" style=\"" + CURSOR + "\" />");
  writer.write("<h4>"  + title + "</h4>");
  writer.write("</td><td class=\"discTria\">&nbsp;</td>");
  writer.write("<td  class=\"itemAction\" style=\"text-align: right;\">");
  List childrenList = component.getChildren();
  for(int i=0; i<childrenList.size(); i++)
  	{
	UIComponent thisComponent = (UIComponent)childrenList.get(i);
    if(thisComponent instanceof org.sakaiproject.tool.messageforums.jsf.BarLinkComponent
       ||thisComponent instanceof HtmlOutputText)
    {
      thisComponent.encodeBegin(context);
      thisComponent.encodeChildren(context);
      thisComponent.encodeEnd(context);
    }
  }
  writer.write("</td></tr></table>");
  writer.write("</"+ BARTAG + ">");
  if(foldDiv) {
    writer.write("<div style=\"display:none\" " +
        " id=\"" + id + "__hide_division_" + "\">");
          } else {
              writer.write("<div style=\"display:block\" " +
                      " id=\"" + id + "__hide_division_" + "\">");
          }
}
 
Example 12
Source File: SeparatedListRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component)
  throws IOException
{
  if (!component.isRendered())
  {
    return;
  }

  String clientId = null;

  if (component.getId() != null &&
    !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
  {
    clientId = component.getClientId(context);
  }

  ResponseWriter writer = context.getResponseWriter();

  if (clientId != null)
  {
     String styleClass = (String) RendererUtil.getAttribute(context, component, "styleClass");
    writer.startElement("div", component);
    writer.writeAttribute("id", clientId, "id");
    writer.writeAttribute("class", styleClass, "class");
  }

  List children = component.getChildren();

  // this is a special separator attribute, not supported by UIData
  String separator = (String) RendererUtil.getAttribute(context, component, "separator");
  if (separator==null) separator=" | ";

  boolean first = true;
  for (Iterator iter = children.iterator(); iter.hasNext();)
  {
    UIComponent child = (UIComponent)iter.next();
     
    if (child.isRendered()) {
       if (!first) writer.write(separator);
 
       RendererUtil.encodeRecursive(context, child);
       first = false;
    }
  } 
    if (clientId != null)
      {
      writer.endElement("div");
    }

  }
 
Example 13
Source File: ToolBarRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component) throws IOException
{
    if (!component.isRendered())
    {
        return;
    }

    String clientId = null;

    if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
    {
        clientId = component.getClientId(context);
    }

    ResponseWriter writer = context.getResponseWriter();

    if (clientId != null)
    {
        writer.startElement("ul", component);
        //writer.append(" class=\"jsfToolbar\" "); // we don't seem to get here
    }

    @SuppressWarnings("unchecked")
    List<UIComponent> children = component.getChildren();

    // this is a special separator attribute, not supported by UIData
    String separator = (String) RendererUtil.getAttribute(context, component, "separator");
    if (separator == null)
    {
        separator = "";
    }

    boolean first = true;
    boolean foundCurrent = false;
    for( UIComponent child : children )
    {
        // should instead leave the span open, and the item should then add class and aria attributes
        // depending on the item is (disabled or not) and then close
        if (child.isRendered()) {
            if (!first)
            {
                writer.write("<li>");
            }
            else
            {
                writer.write("<li class=\"firstToolBarItem\">");
            }
            // SAK-23062 improve JSF options menu
            boolean current = false;
            if (!foundCurrent) {
                // check for the "current" attribute on the custom tag, mark that item as current if it set to true
                boolean hasCurrentIndicated = (child.getAttributes().get("current") != null); // NOTE: child.getAttributes().containsKey("current") will NOT work here
                current = (hasCurrentIndicated && ((Boolean)child.getAttributes().get("current")));
                /* this breaks too many other things
                 * if (!hasCurrentIndicated && !"javax.faces.Link".equals(child.getRendererType())) {
                 * // basically - if it is not a link, it is probably the current item
                 * current = true;
                 * }
                 */
            }
            if (current) {
                foundCurrent = true;
                writer.write("<span class=\"current\">");
            } else {
                writer.write("<span>");
            }
            RendererUtil.encodeRecursive(context, child);
            writer.write("</span></li> ");
            first = false;
        }
    }
    if (clientId != null)
    {
         writer.endElement("ul");
    }
}
 
Example 14
Source File: HideDivisionRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void encodeBegin(FacesContext context, UIComponent component)
throws IOException {

  if (!component.isRendered()) {
    return;
  }

  ResponseWriter writer = context.getResponseWriter();
  String jsfId = (String) RendererUtil.getAttribute(context, component, "id");
  String id = jsfId;

  if (component.getId() != null &&
      !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
  {
    id = component.getClientId(context);
  }

  String title = (String) RendererUtil.getAttribute(context, component, "title");
  Object tmpFoldStr = RendererUtil.getAttribute(context, component, "hideByDefault");
  boolean foldDiv = tmpFoldStr != null && "true".equals(tmpFoldStr);
  String foldImage = foldDiv ? FOLD_IMG_HIDE : FOLD_IMG_SHOW;
  writer.write("<" + BARTAG + " class=\"" + BARSTYLE + "\">");
  writer.write("<table style=\"width: 100%;\" class=\"discTria\" cellpadding=\"0\" cellspacing=\"0\" >");
  writer.write("<tr><td  class=\"discTria\" onclick=\"javascript:showHideDivBlock('" + id +
      "', '" +  RESOURCE_PATH + "');\">" );
  writer.write("  <img id=\"" + id + "__img_hide_division_" + "\" alt=\"" +
      title + "\"");
  writer.write("    src=\""   + foldImage + "\" style=\"" + CURSOR + "\" />");
  writer.write("<h4>"  + title + "</h4>");
  writer.write("</td><td class=\"discTria\">&nbsp;</td>");
  writer.write("<td  class=\"itemAction\" style=\"text-align: right;\">");
  List childrenList = component.getChildren();
  for(int i=0; i<childrenList.size(); i++)
  	{
	UIComponent thisComponent = (UIComponent)childrenList.get(i);
    if(thisComponent instanceof org.sakaiproject.tool.messageforums.jsf.BarLinkComponent
       ||thisComponent instanceof HtmlOutputText)
    {
      thisComponent.encodeBegin(context);
      thisComponent.encodeChildren(context);
      thisComponent.encodeEnd(context);
    }
  }
  writer.write("</td></tr></table>");
  writer.write("</"+ BARTAG + ">");
  if(foldDiv) {
    writer.write("<div style=\"display:none\" " +
        " id=\"" + id + "__hide_division_" + "\">");
          } else {
              writer.write("<div style=\"display:block\" " +
                      " id=\"" + id + "__hide_division_" + "\">");
          }
}
 
Example 15
Source File: RowGroupDataTableRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException {

		UIData uiData = (UIData) component;
		ResponseWriter writer = facesContext.getResponseWriter();

		Styles styles = getStyles(uiData);
		
		int first = uiData.getFirst();
		int rows = uiData.getRows();
		int rowCount = uiData.getRowCount();
		if (rows <= 0)
		{
			rows = rowCount - first;
		}
		int last = first + rows;
		if (last > rowCount)
			last = rowCount;

		for (int i = first; i < last; i++)
		{
			uiData.setRowIndex(i);
			if (!uiData.isRowAvailable())
			{
                log.warn("Row is not available. Rowindex = " + i);
				return;
			}

			int columns = component.getChildCount();
			renderCategoryRow(i, columns, uiData, writer, i==first);

			beforeRow(facesContext, uiData);
			HtmlRendererUtils.writePrettyLineSeparator(facesContext);
			renderRowStart(facesContext, writer, uiData, styles, i);

			List children = component.getChildren();
			for (int j = 0, size = component.getChildCount(); j < size; j++)
			{
				UIComponent child = (UIComponent) children.get(j);
				if(child.isRendered())
				{
					encodeColumnChild(facesContext, writer, uiData, child, styles, j);
				}
			}
			renderRowEnd(facesContext, writer, uiData);

			afterRow(facesContext, uiData);
		}
	}
 
Example 16
Source File: SeparatedListRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component)
  throws IOException
{
  if (!component.isRendered())
  {
    return;
  }

  String clientId = null;

  if (component.getId() != null &&
    !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
  {
    clientId = component.getClientId(context);
  }

  ResponseWriter writer = context.getResponseWriter();

  if (clientId != null)
  {
     String styleClass = (String) RendererUtil.getAttribute(context, component, "styleClass");
    writer.startElement("div", component);
    writer.writeAttribute("id", clientId, "id");
    writer.writeAttribute("class", styleClass, "class");
  }

  List children = component.getChildren();

  // this is a special separator attribute, not supported by UIData
  String separator = (String) RendererUtil.getAttribute(context, component, "separator");
  if (separator==null) separator=" | ";

  boolean first = true;
  for (Iterator iter = children.iterator(); iter.hasNext();)
  {
    UIComponent child = (UIComponent)iter.next();
     
    if (child.isRendered()) {
       if (!first) writer.write(separator);
 
       RendererUtil.encodeRecursive(context, child);
       first = false;
    }
  } 
    if (clientId != null)
      {
      writer.endElement("div");
    }

  }
 
Example 17
Source File: SeparatedListRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component)
  throws IOException
{
  if (!component.isRendered())
  {
    return;
  }

  String clientId = null;

  if (component.getId() != null &&
    !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
  {
    clientId = component.getClientId(context);
  }

  ResponseWriter writer = context.getResponseWriter();

  if (clientId != null)
  {
     String styleClass = (String) RendererUtil.getAttribute(context, component, "styleClass");
    writer.startElement("div", component);
    writer.writeAttribute("id", clientId, "id");
    writer.writeAttribute("class", styleClass, "class");
  }

  List children = component.getChildren();

  // this is a special separator attribute, not supported by UIData
  String separator = (String) RendererUtil.getAttribute(context, component, "separator");
  if (separator==null) separator=" | ";

  boolean first = true;
  for (Iterator iter = children.iterator(); iter.hasNext();)
  {
    UIComponent child = (UIComponent)iter.next();
     
    if (child.isRendered()) {
       if (!first) writer.write(separator);
 
       RendererUtil.encodeRecursive(context, child);
       first = false;
    }
  } 
    if (clientId != null)
      {
      writer.endElement("div");
    }

  }
 
Example 18
Source File: ToolBarRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component) throws IOException
{
    if (!component.isRendered())
    {
        return;
    }

    String clientId = null;

    if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
    {
        clientId = component.getClientId(context);
    }

    ResponseWriter writer = context.getResponseWriter();

    if (clientId != null)
    {
        writer.startElement("ul", component);
        //writer.append(" class=\"jsfToolbar\" "); // we don't seem to get here
    }

    @SuppressWarnings("unchecked")
    List<UIComponent> children = component.getChildren();

    // this is a special separator attribute, not supported by UIData
    String separator = (String) RendererUtil.getAttribute(context, component, "separator");
    if (separator == null)
    {
        separator = "";
    }

    boolean first = true;
    boolean foundCurrent = false;
    for( UIComponent child : children )
    {
        // should instead leave the span open, and the item should then add class and aria attributes
        // depending on the item is (disabled or not) and then close
        if (child.isRendered()) {
            if (!first)
            {
                writer.write("<li>");
            }
            else
            {
                writer.write("<li class=\"firstToolBarItem\">");
            }
            // SAK-23062 improve JSF options menu
            boolean current = false;
            if (!foundCurrent) {
                // check for the "current" attribute on the custom tag, mark that item as current if it set to true
                boolean hasCurrentIndicated = (child.getAttributes().get("current") != null); // NOTE: child.getAttributes().containsKey("current") will NOT work here
                current = (hasCurrentIndicated && ((Boolean)child.getAttributes().get("current")));
                /* this breaks too many other things
                 * if (!hasCurrentIndicated && !"javax.faces.Link".equals(child.getRendererType())) {
                 * // basically - if it is not a link, it is probably the current item
                 * current = true;
                 * }
                 */
            }
            if (current) {
                foundCurrent = true;
                writer.write("<span class=\"current\">");
            } else {
                writer.write("<span>");
            }
            RendererUtil.encodeRecursive(context, child);
            writer.write("</span></li> ");
            first = false;
        }
    }
    if (clientId != null)
    {
         writer.endElement("ul");
    }
}
 
Example 19
Source File: ToolBarRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component) throws IOException
{
    if (!component.isRendered())
    {
        return;
    }

    String clientId = null;

    if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
    {
        clientId = component.getClientId(context);
    }

    ResponseWriter writer = context.getResponseWriter();

    if (clientId != null)
    {
        writer.startElement("ul", component);
        //writer.append(" class=\"jsfToolbar\" "); // we don't seem to get here
    }

    @SuppressWarnings("unchecked")
    List<UIComponent> children = component.getChildren();

    // this is a special separator attribute, not supported by UIData
    String separator = (String) RendererUtil.getAttribute(context, component, "separator");
    if (separator == null)
    {
        separator = "";
    }

    boolean first = true;
    boolean foundCurrent = false;
    for( UIComponent child : children )
    {
        // should instead leave the span open, and the item should then add class and aria attributes
        // depending on the item is (disabled or not) and then close
        if (child.isRendered()) {
            if (!first)
            {
                writer.write("<li>");
            }
            else
            {
                writer.write("<li class=\"firstToolBarItem\">");
            }
            // SAK-23062 improve JSF options menu
            boolean current = false;
            if (!foundCurrent) {
                // check for the "current" attribute on the custom tag, mark that item as current if it set to true
                boolean hasCurrentIndicated = (child.getAttributes().get("current") != null); // NOTE: child.getAttributes().containsKey("current") will NOT work here
                current = (hasCurrentIndicated && ((Boolean)child.getAttributes().get("current")));
                /* this breaks too many other things
                 * if (!hasCurrentIndicated && !"javax.faces.Link".equals(child.getRendererType())) {
                 * // basically - if it is not a link, it is probably the current item
                 * current = true;
                 * }
                 */
            }
            if (current) {
                foundCurrent = true;
                writer.write("<span class=\"current\">");
            } else {
                writer.write("<span>");
            }
            RendererUtil.encodeRecursive(context, child);
            writer.write("</span></li> ");
            first = false;
        }
    }
    if (clientId != null)
    {
         writer.endElement("ul");
    }
}
 
Example 20
Source File: RowGroupDataTableRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException {

		UIData uiData = (UIData) component;
		ResponseWriter writer = facesContext.getResponseWriter();

		Styles styles = getStyles(uiData);
		
		int first = uiData.getFirst();
		int rows = uiData.getRows();
		int rowCount = uiData.getRowCount();
		if (rows <= 0)
		{
			rows = rowCount - first;
		}
		int last = first + rows;
		if (last > rowCount)
			last = rowCount;

		for (int i = first; i < last; i++)
		{
			uiData.setRowIndex(i);
			if (!uiData.isRowAvailable())
			{
                log.warn("Row is not available. Rowindex = " + i);
				return;
			}

			int columns = component.getChildCount();
			renderCategoryRow(i, columns, uiData, writer, i==first);

			beforeRow(facesContext, uiData);
			HtmlRendererUtils.writePrettyLineSeparator(facesContext);
			renderRowStart(facesContext, writer, uiData, styles, i);

			List children = component.getChildren();
			for (int j = 0, size = component.getChildCount(); j < size; j++)
			{
				UIComponent child = (UIComponent) children.get(j);
				if(child.isRendered())
				{
					encodeColumnChild(facesContext, writer, uiData, child, styles, j);
				}
			}
			renderRowEnd(facesContext, writer, uiData);

			afterRow(facesContext, uiData);
		}
	}