Search in sources :

Example 11 with FacesContext

use of javax.faces.context.FacesContext in project ART-TIME by Artezio.

the class Sheet method updateDirtyRows.

public void updateDirtyRows(Set<Object> dirtyRows) {
    FacesContext context = FacesContext.getCurrentInstance();
    renderRowUpdateScript(context, dirtyRows);
    setRowIndex(context, -1);
}
Also used : FacesContext(javax.faces.context.FacesContext)

Example 12 with FacesContext

use of javax.faces.context.FacesContext in project ART-TIME by Artezio.

the class Sheet method sortAndFilter.

/**
 * Sorts and filters the data
 */
@SuppressWarnings("unchecked")
public void sortAndFilter() {
    sortedList = new ArrayList<Object>();
    rowMap = new HashMap<Object, RowMap>();
    Collection<?> values = (Collection<?>) getValue();
    if (values == null || values.isEmpty())
        return;
    boolean filters = false;
    for (Column col : getColumns()) if (StringUtils.isNotEmpty(col.getFilterValue())) {
        filters = true;
        break;
    }
    FacesContext context = FacesContext.getCurrentInstance();
    Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
    if (filters) {
        // iterate and add those matching the filters
        String var = getVar();
        for (Object obj : values) {
            requestMap.put(var, obj);
            try {
                if (matchesFilter(obj))
                    sortedList.add(obj);
            } finally {
                requestMap.remove(var);
            }
        }
    } else
        sortedList.addAll(values);
    ValueExpression veSortBy = this.getValueExpression(PropertyKeys.sortBy.name());
    if (veSortBy != null) {
        // Collections.sort(sortedList, new BeanPropertyComparator(veSortBy, getVar(), convertSortOrder(), null));
        throw new UnsupportedOperationException("Not implemented for PrimeFaces 5.2");
    }
    reMapRows();
}
Also used : FacesContext(javax.faces.context.FacesContext) ValueExpression(javax.el.ValueExpression) Collection(java.util.Collection)

Example 13 with FacesContext

use of javax.faces.context.FacesContext in project ART-TIME by Artezio.

the class Sheet method resolveWidgetVar.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.primefaces.component.api.Widget#resolveWidgetVar()
	 */
@Override
public String resolveWidgetVar() {
    FacesContext context = FacesContext.getCurrentInstance();
    String userWidgetVar = (String) getAttributes().get("widgetVar");
    if (userWidgetVar != null)
        return userWidgetVar;
    else
        return "widget_" + getClientId(context).replaceAll("-|" + UINamingContainer.getSeparatorChar(context), "_");
}
Also used : FacesContext(javax.faces.context.FacesContext)

Example 14 with FacesContext

use of javax.faces.context.FacesContext in project ART-TIME by Artezio.

the class FacesMessageInterceptor method aroundInvoke.

@AroundInvoke
public Object aroundInvoke(InvocationContext ic) throws Exception {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Object result = ic.proceed();
    if (facesContext == null)
        return result;
    ExternalContext externalContext = facesContext.getExternalContext();
    externalContext.getFlash().setKeepMessages(true);
    FacesMessage annotation = ic.getMethod().getAnnotation(FacesMessage.class);
    String onCompleteMessageKey = annotation.onCompleteMessageKey();
    Locale locale = externalContext.getRequestLocale();
    String messageBundleName = facesContext.getApplication().getMessageBundle();
    ResourceBundle messageBundle = ResourceBundle.getBundle(messageBundleName, locale);
    facesContext.addMessage(null, new javax.faces.application.FacesMessage(messageBundle.getString(onCompleteMessageKey)));
    return result;
}
Also used : Locale(java.util.Locale) FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) ResourceBundle(java.util.ResourceBundle) AroundInvoke(javax.interceptor.AroundInvoke)

Example 15 with FacesContext

use of javax.faces.context.FacesContext in project Payara by payara.

the class JSFTestServlet method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
    LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    ServletContext context = getServletContext();
    FacesContext facesContext = facesContextFactory.getFacesContext(context, request, response, lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE));
    Application application = facesContext.getApplication();
    ViewHandler viewHandler = application.getViewHandler();
    UIViewRoot viewRoot = viewHandler.createView(facesContext, null);
    facesContext.setViewRoot(viewRoot);
    PrintWriter pw = response.getWriter();
    pw.println("Created viewRoot " + viewRoot);
    pw.flush();
    pw.close();
}
Also used : FacesContext(javax.faces.context.FacesContext) ViewHandler(javax.faces.application.ViewHandler) FacesContextFactory(javax.faces.context.FacesContextFactory) LifecycleFactory(javax.faces.lifecycle.LifecycleFactory) ServletContext(javax.servlet.ServletContext) Application(javax.faces.application.Application) UIViewRoot(javax.faces.component.UIViewRoot) PrintWriter(java.io.PrintWriter)

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