use of javax.faces.context.FacesContext in project opentheso by miledrousset.
the class SelectedThesaurus method getBundlePref.
/**
* ************************************ INITIALISATION
* *************************************
*/
/**
* Récupération des préférences
*
* @return la ressourceBundle des préférences
*/
private ResourceBundle getBundlePref() {
FacesContext context = FacesContext.getCurrentInstance();
ResourceBundle bundlePref = context.getApplication().getResourceBundle(context, "pref");
return bundlePref;
}
use of javax.faces.context.FacesContext in project opentheso by miledrousset.
the class SearchCandidatBean method refreshView.
public void refreshView() {
FacesContext context = FacesContext.getCurrentInstance();
String viewId = context.getViewRoot().getViewId();
ViewHandler handler = context.getApplication().getViewHandler();
UIViewRoot root = handler.createView(context, viewId);
root.setViewId(viewId);
context.setViewRoot(root);
}
use of javax.faces.context.FacesContext in project opentheso by miledrousset.
the class SelectedThesaurus method maj.
/**
* ************************************ MISE A JOUR
* *************************************
*/
/**
* Met à jour le thésaurus courant lors d'un changement de thésaurus
*/
public void maj() {
tree.getSelectedTerme().reInitTerme();
tree.reInit();
tree.initTree(null, null);
statBean.reInit();
ThesaurusHelper th = new ThesaurusHelper();
nodePreference = tree.getSelectedTerme().getUser().getThesaurusPreferences(thesaurus.getId_thesaurus(), workLanguage);
if (th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), nodePreference.getSourceLang()) != null) {
thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), nodePreference.getSourceLang());
tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
tree.setIdThesoSelected(thesaurus.getId_thesaurus());
tree.setDefaultLanguage(thesaurus.getLanguage());
} else {
thesaurus.setLanguage("");
}
uTree.reInit();
uTree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
candidat.maj(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
if (tree != null) {
tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
}
vue.setCreat(false);
// #jm pour la page de statistiques
vue.setStatTheso(false);
// idem
vue.setStatCpt(false);
majPref();
if (selectedTerme != null) {
selectedTerme.initTerme();
}
tree.getSelectedTerme().getUser().setIdTheso(thesaurus.getId_thesaurus());
if ((user.getUser().getName() != null) && (user.isIsHaveWriteToCurrentThesaurus())) {
String message = "drag & dop activé !";
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("", "info : " + message));
}
}
use of javax.faces.context.FacesContext in project Payara by payara.
the class ListTreeAdaptor method getChildTreeNodeObjects.
/**
* <p> Returns child <code>TreeNode</code>s for the given
* <code>TreeNode</code> model Object.</p>
*/
public List getChildTreeNodeObjects(Object nodeObject) {
if (nodeObject == null) {
return null;
}
if ((nodeObject instanceof Integer) && nodeObject.equals(TOP_ID)) {
// Find/Return children here
if (_children != null) {
return _children;
}
// Find the children...
FacesContext ctx = FacesContext.getCurrentInstance();
// This is the descriptor for this dynamic TreeNode, it contains all
// information (options) necessary for this Adaptor
LayoutComponent desc = getLayoutComponent();
Object val = desc.getOption("children");
if (val == null) {
throw new IllegalArgumentException("'children' must be specified!");
}
val = desc.resolveValue(ctx, getParentUIComponent(), val.toString());
if ((val != null) && (val instanceof Map)) {
_childMap = (Map<String, Object>) val;
val = new ArrayList<Object>(_childMap.keySet());
Collections.sort((List) val);
}
_children = (List<Object>) val;
// Ok, we got the result, provide an event in case we want to
// do some filtering
Object retVal = getLayoutComponent().dispatchHandlers(ctx, FilterTreeEvent.EVENT_TYPE, new FilterTreeEvent(getParentUIComponent(), _children));
if ((retVal != null) && (retVal instanceof List)) {
// We have a return value, use it instead of the original list
_children = (List<Object>) retVal;
}
} else {
// Currently multiple levels are not implemented
return null;
}
return _children;
}
use of javax.faces.context.FacesContext in project Payara by payara.
the class MiscUtil method setValueExpression.
/**
* <p>This utility method can be used to create a ValueExpression and set its value.
* An example usage might look like this:</p>
* <code>
* ValueExpression ve = MiscUtil.setValueExpression("#{myMap}", new HashMap());
* </code>
* @param expression The expression to create. Note that this requires the #{ and } wrappers.
* @param value The value to which to set the ValueExpression
* @return The newly created ValueExpression
*/
public static ValueExpression setValueExpression(String expression, Object value) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ValueExpression ve = facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), expression, Object.class);
ve.setValue(facesContext.getELContext(), value);
return ve;
}
Aggregations