Java Code Examples for javax.faces.component.UIViewRoot#getViewMap()

The following examples show how to use javax.faces.component.UIViewRoot#getViewMap() . 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: AddResourcesListener.java    From BootsFaces-OSP with Apache License 2.0 6 votes vote down vote up
/**
 * Check if there is almost one bootsfaces component in page. If yes, load the
 * correct items.
 *
 * To ensure that, it checks first the viewMap to find specific bootsfaces key.
 * If it found nothing, it check for components that has as a resource lib, the
 * "bsf" lib.
 *
 * @param root    the UIViewRoot
 * @param context the faces context
 * @return
 */
private boolean ensureExistBootsfacesComponent(UIViewRoot root, FacesContext context) {
	Map<String, Object> viewMap = root.getViewMap();

	// check explicit js request
	if (viewMap.get(RESOURCE_KEY) != null) {
		return true;
	}
	// check explicit css request
	if (viewMap.get(THEME_RESOURCE_KEY) != null) {
		return true;
	}
	// check explicit css request
	if (viewMap.get(EXT_RESOURCE_KEY) != null) {
		return true;
	}
	// check referenced bsf request
	if (findBsfComponent(root, C.BSF_LIBRARY) != null) {
		return true;
	}

	return false;
}
 
Example 2
Source File: AddResourcesListener.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
public static void setFontAwesomeVersion(int version, Object uiComponent) {
	FacesContext context = FacesContext.getCurrentInstance();
	UIViewRoot root = context.getViewRoot();
	Map<String, Object> viewMap = root.getViewMap();

	if (version != 4) {
		@SuppressWarnings("unchecked")
		Map<Object, Boolean> v5 = (Map<Object, Boolean>) viewMap.get(FONTAWESOME_NEW_VERSION);
		if (null == v5) {
			v5 = new HashMap<Object, Boolean>();
			viewMap.put(FONTAWESOME_NEW_VERSION, v5);
		}
		v5.put(uiComponent, true);
	}

	String _version = (String) viewMap.get(FONTAWESOME_VERSION);
	if (_version != null) {
		if (!_version.contains(String.valueOf(version))) {
			viewMap.put(FONTAWESOME_VERSION, String.valueOf(_version + "," + version));
		}
	} else {
		if (viewMap.containsKey(FONTAWESOME_USED)) {
			viewMap.put(FONTAWESOME_VERSION, "4," + String.valueOf(version));
		} else {
			viewMap.put(FONTAWESOME_VERSION, String.valueOf(version));
		}
	}

	LOGGER.log(Level.FINER, "by setFontAwesomeVersion - viewMap(FONTAWESOME_VERSION) is {0}",
			viewMap.get(FONTAWESOME_VERSION));
}
 
Example 3
Source File: AddResourcesListener.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static void setNeedsFontsAwesome(Object uiComponent) {
	FacesContext context = FacesContext.getCurrentInstance();
	UIViewRoot root = context.getViewRoot();
	Map<String, Object> viewMap = root.getViewMap();
	ArrayList<Object> list = (ArrayList<Object>) viewMap.get(FONTAWESOME_USED);
	if (list == null) {
		list = new ArrayList<Object>();
		viewMap.put(FONTAWESOME_USED, list);
	}
	list.add(uiComponent);
}
 
Example 4
Source File: AddResourcesListener.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
private boolean needsFontAwesome4() {
	FacesContext context = FacesContext.getCurrentInstance();
	UIViewRoot root = context.getViewRoot();
	Map<String, Object> viewMap = root.getViewMap();
	@SuppressWarnings("unchecked")
	Map<Object, Boolean> v5 = (Map<Object, Boolean>) viewMap.get(FONTAWESOME_NEW_VERSION);
	@SuppressWarnings("unchecked")
	ArrayList<Object> all = (ArrayList<Object>) viewMap.get(FONTAWESOME_USED);
	viewMap.remove(FONTAWESOME_NEW_VERSION);
	viewMap.remove(FONTAWESOME_USED);
	if (all == null) {
		return false;
	}
	if (v5 == null) {
		all.clear();
		return true;
	}
	boolean v4 = false;
	for (Object o : all) {
		if (!v5.containsKey(o)) {
			v4 = true;
			break;
		}
	}
	all.clear();
	v5.clear();
	return v4;
}
 
Example 5
Source File: ViewScopedContext.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected Map<String, Object> getViewMap()
{
    UIViewRoot viewRoot = getViewRoot();

    if (viewRoot != null)
    {
        return viewRoot.getViewMap(true);
    }

    return null;
}
 
Example 6
Source File: DojoCheckBoxDefaultValueDisabledTest.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
/**
 * @param root
 * @return
 */
@SuppressWarnings("unchecked")
private Map<String, Object> getViewMap(UIViewRoot root) {
    return root.getViewMap();
}
 
Example 7
Source File: DojoTypeTest.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private Map<String, Object> getViewMap(UIViewRoot root) {
    return root.getViewMap();
}