use of org.primefaces.expression.SearchExpressionHint in project primefaces by primefaces.
the class RowExpressionResolver method resolveClientIds.
@Override
public String resolveClientIds(FacesContext context, UIComponent source, UIComponent last, String expression, Set<SearchExpressionHint> hints) {
int row = validate(context, source, last, expression);
UIData data = (UIData) last;
char separatorChar = UINamingContainer.getSeparatorChar(context);
StringBuilder clientIds = new StringBuilder();
for (UIComponent column : data.getChildren()) {
// handle dynamic columns
if (column instanceof Columns) {
List<DynamicColumn> dynamicColumns = ((Columns) column).getDynamicColumns();
for (int i = 0; i < dynamicColumns.size(); i++) {
DynamicColumn dynamicColumn = dynamicColumns.get(i);
for (UIComponent comp : column.getChildren()) {
if (clientIds.length() > 0) {
clientIds.append(" ");
}
clientIds.append(data.getClientId(context));
clientIds.append(separatorChar);
clientIds.append(row);
clientIds.append(separatorChar);
clientIds.append(dynamicColumn.getId());
clientIds.append(separatorChar);
clientIds.append(i);
clientIds.append(separatorChar);
clientIds.append(comp.getId());
}
}
} else if (column instanceof UIColumn) {
for (UIComponent cell : column.getChildren()) {
if (clientIds.length() > 0) {
clientIds.append(" ");
}
clientIds.append(data.getClientId(context));
clientIds.append(separatorChar);
clientIds.append(row);
clientIds.append(separatorChar);
clientIds.append(cell.getId());
}
}
}
return clientIds.toString();
}
use of org.primefaces.expression.SearchExpressionHint in project primefaces by primefaces.
the class UITable method updateFilterByWithGlobalFilter.
default void updateFilterByWithGlobalFilter(FacesContext context, Map<String, FilterMeta> filterBy, AtomicBoolean filtered) {
// #globalFilter sets the default value, which will be assigned to the "globalFilter" input
String globalFilterDefaultValue = getGlobalFilter();
// if #globalFilter is set, the "globalFilter" is mandatory
Set<SearchExpressionHint> hint = LangUtils.isBlank(globalFilterDefaultValue) ? SearchExpressionUtils.SET_IGNORE_NO_RESULT : SearchExpressionUtils.SET_NONE;
UIComponent globalFilterComponent = SearchExpressionFacade.resolveComponent(context, (UIComponent) this, GLOBAL_FILTER_COMPONENT_ID, hint);
if (globalFilterComponent != null) {
if (globalFilterComponent instanceof ValueHolder) {
((ValueHolder) globalFilterComponent).setValue(globalFilterDefaultValue);
}
FilterMeta globalFilterBy = FilterMeta.of(globalFilterDefaultValue, getGlobalFilterFunction());
filterBy.put(globalFilterBy.getColumnKey(), globalFilterBy);
filtered.set(filtered.get() || globalFilterBy.isActive());
}
}
use of org.primefaces.expression.SearchExpressionHint in project primefaces by primefaces.
the class PreviousExpressionResolver method resolveComponent.
@Override
public UIComponent resolveComponent(FacesContext context, UIComponent source, UIComponent last, String expression, Set<SearchExpressionHint> hints) {
UIComponent parent = last.getParent();
if (parent.getChildCount() > 1) {
List<UIComponent> children = parent.getChildren();
int index = children.indexOf(last);
if (index > 0) {
int nextIndex = -1;
do {
index--;
String className = children.get(index).getClass().getName();
if (!className.contains("UIInstructions") && !className.contains("UILeaf")) {
nextIndex = index;
}
} while (nextIndex == -1 && index > 0);
if (nextIndex != -1) {
return children.get(nextIndex);
}
}
}
return null;
}
use of org.primefaces.expression.SearchExpressionHint in project primefaces by primefaces.
the class ChildExpressionResolver method resolveComponent.
@Override
public UIComponent resolveComponent(FacesContext context, UIComponent source, UIComponent last, String expression, Set<SearchExpressionHint> hints) {
Matcher matcher = PATTERN.matcher(expression);
if (matcher.matches()) {
int childNumber = Integer.parseInt(matcher.group(1));
if (childNumber + 1 > last.getChildCount()) {
throw new FacesException("Component with clientId \"" + last.getClientId(context) + "\" has fewer children as \"" + childNumber + "\". Expression: \"" + expression + "\"");
}
List<UIComponent> list = last.getChildren();
int count = 0;
for (int i = 0; i < last.getChildCount(); i++) {
String className = list.get(i).getClass().getName();
if (!className.contains("UIInstructions") && !className.contains("UILeaf")) {
count++;
}
if (count == childNumber + 1) {
return last.getChildren().get(childNumber);
}
}
if (count < childNumber) {
throw new FacesException("Component with clientId \"" + last.getClientId(context) + "\" has fewer children as \"" + childNumber + "\". Expression: \"" + expression + "\"");
}
} else {
throw new FacesException("Expression does not match following pattern @child(n). Expression: \"" + expression + "\"");
}
return null;
}
use of org.primefaces.expression.SearchExpressionHint in project primefaces by primefaces.
the class NextExpressionResolver method resolveComponent.
@Override
public UIComponent resolveComponent(FacesContext context, UIComponent source, UIComponent last, String expression, Set<SearchExpressionHint> hints) {
UIComponent parent = last.getParent();
if (parent.getChildCount() > 1) {
List<UIComponent> children = parent.getChildren();
int index = children.indexOf(last);
if (index < parent.getChildCount() - 1) {
int nextIndex = -1;
do {
index++;
String className = children.get(index).getClass().getName();
if (!className.contains("UIInstructions") && !className.contains("UILeaf")) {
nextIndex = index;
}
} while (nextIndex == -1 && index < parent.getChildCount() - 1);
if (nextIndex != -1) {
return children.get(nextIndex);
}
}
}
return null;
}
Aggregations