Basically the idea is to have the same utility method
similar to FacesContext.getCurrentInstance()
the implementation could be something like:
/**
* @return the current {@link FaceletContext} from the attributes of the current {@link FacesContext}
*/
public static FaceletContext getCurrentInstance() {
return getCurrentInstance(FacesContext.getCurrentInstance());
}
/**
* @return the current {@link FaceletContext} from the attributes of the passed {@link FacesContext}
* @param context the current FacesContext
*/
public static FaceletContext getCurrentInstance(FacesContext context) {
return (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
}