Java Code Examples for org.apache.wicket.Component#getParent()

The following examples show how to use org.apache.wicket.Component#getParent() . 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: WicketUtils.java    From onedev with MIT License 5 votes vote down vote up
/**
 * Get list of parent components (including current component) of specified clazz
 * @param component
 * 			starting component
 * @param clazz
 * 			clazz to check
 * @return
 * 			list of parent components of specified clazz, with inner component comes first
 */
@SuppressWarnings("unchecked")
public static <T> List<T> findParents(Component component, Class<T> clazz) {
	List<T> parents = new ArrayList<>();
	Component current = component;
	do {
		if (clazz.isAssignableFrom(current.getClass()))
			parents.add((T) current);
		current = current.getParent();
	} while (current != null);

	return parents;
}
 
Example 2
Source File: ChartJSBehavior.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(final Component component, final IHeaderResponse response) {
    super.renderHead(component, response);

    response.render(OnDomReadyHeaderItem.forScript(
            "WicketCharts['" + component.getMarkupId() + "']=buildChart('" + component.getMarkupId() + "');"));

    if (component.getParent() instanceof ChartJSPanel) {
        response.render(OnDomReadyHeaderItem.forScript(((ChartJSPanel) component.getParent()).generateChart()));
    }
}
 
Example 3
Source File: ErrorHighlightBehavior.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onComponentTag(final Component component, final ComponentTag tag)
{
  if (component instanceof FormComponent< ? >) {
    final FormComponent< ? > fc = (FormComponent< ? >) component;
    if (fc instanceof AbstractSelectPanel< ? > == true) {
      // Do ignore the AbstractSelectPanels, otherwise the icons looks not very pretty on colored background.
      return;
    }
    if (fc.isValid() == true) {
      return;
    }
  } else if (component.getParent() != null && component.getParent() instanceof FieldsetPanel) {
    final FieldsetPanel fs = (FieldsetPanel) component.getParent();
    if (fs.isValid() == true) {
      return;
    }
  } else {
    return;
  }
  final String value = tag.getAttribute("class");
  if (StringUtils.isEmpty(value) == true) {
    tag.put("class", "has-error");
  } else {
    tag.put("class", value + " has-error");
  }
}
 
Example 4
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isParent(final Component parent, final Component descendant)
{
  final MarkupContainer p = descendant.getParent();
  if (p == null) {
    return false;
  } else if (p == parent) {
    return true;
  } else {
    return isParent(parent, p);
  }
}