Search in sources :

Example 16 with FacesContext

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;
}
Also used : FacesContext(javax.faces.context.FacesContext) ResourceBundle(java.util.ResourceBundle)

Example 17 with FacesContext

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);
}
Also used : PrimeFacesContext(org.primefaces.context.PrimeFacesContext) FacesContext(javax.faces.context.FacesContext) ViewHandler(javax.faces.application.ViewHandler) UIViewRoot(javax.faces.component.UIViewRoot)

Example 18 with FacesContext

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));
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) FacesMessage(javax.faces.application.FacesMessage)

Example 19 with FacesContext

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;
}
Also used : FacesContext(javax.faces.context.FacesContext) ArrayList(java.util.ArrayList) List(java.util.List) LayoutComponent(com.sun.jsftemplating.layout.descriptors.LayoutComponent) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with FacesContext

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;
}
Also used : FacesContext(javax.faces.context.FacesContext) ValueExpression(javax.el.ValueExpression)

Aggregations

FacesContext (javax.faces.context.FacesContext)361 NodeRef (org.alfresco.service.cmr.repository.NodeRef)61 Node (org.alfresco.web.bean.repository.Node)44 UserTransaction (javax.transaction.UserTransaction)43 ArrayList (java.util.ArrayList)33 HashMap (java.util.HashMap)28 IOException (java.io.IOException)27 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)27 ExternalContext (javax.faces.context.ExternalContext)26 SelectItem (javax.faces.model.SelectItem)26 QName (org.alfresco.service.namespace.QName)25 FacesMessage (javax.faces.application.FacesMessage)24 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)22 Map (java.util.Map)21 ResourceBundle (java.util.ResourceBundle)20 HttpServletResponse (javax.servlet.http.HttpServletResponse)19 MapNode (org.alfresco.web.bean.repository.MapNode)18 UIViewRoot (javax.faces.component.UIViewRoot)17 HttpServletRequest (javax.servlet.http.HttpServletRequest)16 Serializable (java.io.Serializable)15