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

The following examples show how to use javax.faces.component.UIComponent#getClass() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
public List<UIComponent> resolve(UIComponent component, List<UIComponent> parentComponents, String currentId,
			String originalExpression, String[] parameters) {

		List<UIComponent> result = new ArrayList<UIComponent>();
//		for (UIComponent parent : parentComponents) {
			UIComponent c = component;

			while (c != null && c.getClass() != UIViewRoot.class) {
				if (UIForm.class.isAssignableFrom(c.getClass())) {
					result.add(c);
					break;
				}
				c = c.getParent();
			}
//		}
		if (result.size() > 0) {
			return result;
		}
		throw new FacesException("Invalid search expression - the component isn't inside a form " + originalExpression);

	}
 
Example 2
private void addResourceIfNecessary(UIViewRoot root, FacesContext context, UIComponent output, Class<?> clazz) {
	for (UIComponent c : root.getComponentResources(context, "head")) {
		if (c.getClass() == clazz) {
			LOGGER.log(Level.FINER, "by addResourceIfNecessary - find existing class {0}", clazz);

			// remove old
			root.removeComponentResource(context, c, "head");

			// add new
			root.addComponentResource(context, output, "head");
			return;
		}
	}
	// resource not found yet, so add it now
	root.addComponentResource(context, output, "head");
}
 
Example 3
public List<UIComponent> resolve(UIComponent component, List<UIComponent> parentComponents, String currentId,
		String originalExpression, String[] parameters) {
	
	
	List<UIComponent> result = new ArrayList<UIComponent>();
	boolean isButton = component instanceof CommandButton || component instanceof NavCommandLink;
	isButton |= component instanceof Poll;
	if (!isButton) {
		result.add(component);
		return result;
	}

	UIComponent c = component;

	while (c != null && c.getClass() != UIViewRoot.class) {
		if (UIForm.class.isAssignableFrom(c.getClass())) {
			result.add(c);
			break;
		}
		c = c.getParent();
	}
	if (result.size() > 0) {
		return result;
	}

	c = component;

	while (c != null && c.getClass() != UIViewRoot.class) {
		if (NamingContainer.class.isAssignableFrom(c.getClass())) {
			result.add(c);
			break;
		}
		c = c.getParent();
	}
	if (result.size() > 0) {
		return result;
	}
	else {
		result.add(component);
		return result;
	}
}