use of javax.faces.component.UIViewRoot in project rubia-forums by flashboss.
the class JSFUtil method getComponentValue.
/**
* @author sshah
*
* @param componentId
* the id component to check
*
* @return the value of the choosen component
*/
public static String getComponentValue(String componentId) {
String value = null;
UIViewRoot root = getCurrentInstance().getViewRoot();
UIComponent component = root.findComponent(componentId);
if (component != null) {
Object o = component.getValueExpression("value").getValue(getCurrentInstance().getELContext());
value = (String) o;
}
return value;
}
use of javax.faces.component.UIViewRoot in project rubia-forums by flashboss.
the class JSFUtil method removeComponent.
/**
* @author sshah
*
* @param componentId
* the id component to check
*/
public static void removeComponent(String componentId) {
UIViewRoot root = getCurrentInstance().getViewRoot();
UIComponent component = root.findComponent(componentId);
if (component != null) {
UIComponent parent = component.getParent();
parent.getChildren().remove(component);
}
}
use of javax.faces.component.UIViewRoot in project rubia-forums by flashboss.
the class JSFUtil method getBundleMessage.
/**
* @param bundleName
* the name of the bundle
* @param messageKey
* the key of the bundle to find
*
* @return the value for the requested id
*/
public static String getBundleMessage(String bundleName, String messageKey) {
String bundleMessage = null;
// Getting ResourceBundle with current Locale
FacesContext ctx = getCurrentInstance();
UIViewRoot uiRoot = ctx.getViewRoot();
Locale locale = uiRoot.getLocale();
ClassLoader ldr = currentThread().getContextClassLoader();
ResourceBundle bundle = getBundle(bundleName, locale, ldr);
bundleMessage = bundle.getString(messageKey);
return bundleMessage;
}
use of javax.faces.component.UIViewRoot in project rubia-forums by flashboss.
the class ThemeHelper method getFolderType.
/**
* @param topic
* the topic to find
*
* @return the folder type
*/
public String getFolderType(Topic topic) {
// Getting ResourceBundle with current Locale
FacesContext ctx = getCurrentInstance();
UIViewRoot uiRoot = ctx.getViewRoot();
Locale locale = uiRoot.getLocale();
ClassLoader ldr = currentThread().getContextClassLoader();
ResourceBundle bundle = getBundle("ResourceJSF", locale, ldr);
String topicType = null;
int topicStatus = topic.getStatus();
FolderType folderType = theme.getFolderType(topic.getType(), topicStatus, topic.getReplies() >= hotThreshold);
try {
if (topicStatus != Constants.TOPIC_MOVED) {
try {
topicType = bundle.getString(folderType.type);
} catch (MissingResourceException e) {
topicType = "";
}
} else {
topicType = bundle.getString("Topic_Moved");
}
} catch (Exception e) {
return "";
}
return topicType;
}
use of javax.faces.component.UIViewRoot in project joinfaces by joinfaces.
the class ViewScope method getViewRoot.
@NonNull
private UIViewRoot getViewRoot() {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext == null) {
throw new IllegalStateException("No FacesContext found.");
}
UIViewRoot viewRoot = facesContext.getViewRoot();
if (viewRoot == null) {
throw new IllegalStateException("No ViewRoot found");
}
return viewRoot;
}
Aggregations