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);
}
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();
}
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), "_");
}
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;
}
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();
}
Aggregations