Search in sources :

Example 1 with UITree

use of org.primefaces.component.api.UITree in project primefaces by primefaces.

the class UIDataContextCallback method invokeContextCallback.

@Override
public void invokeContextCallback(FacesContext fc, UIComponent component) {
    String[] idTokens = dragId.split(String.valueOf(UINamingContainer.getSeparatorChar(fc)));
    String dataId = idTokens[idTokens.length - 2];
    if (component instanceof UITree) {
        UITree uiTree = (UITree) component;
        uiTree.setRowKey(dataId);
        data = uiTree.getRowNode();
        uiTree.setRowKey(null);
    } else {
        UIData uiData = (UIData) component;
        uiData.setRowIndex(Integer.parseInt(dataId));
        data = uiData.getRowData();
        uiData.setRowIndex(-1);
    }
}
Also used : UITree(org.primefaces.component.api.UITree) UIData(javax.faces.component.UIData)

Example 2 with UITree

use of org.primefaces.component.api.UITree in project primefaces by primefaces.

the class CellEditEvent method resolveValue.

private T resolveValue() {
    if (source instanceof UIData) {
        DataTable data = (DataTable) source;
        data.setRowModel(rowIndex);
    } else if (source instanceof UITree) {
        TreeTable data = (TreeTable) source;
        data.setRowKey(data.getValue(), rowKey);
    }
    if (column.isDynamic()) {
        DynamicColumn dynamicColumn = (DynamicColumn) column;
        dynamicColumn.applyStatelessModel();
    }
    T value = null;
    for (UIComponent child : column.getChildren()) {
        if (child instanceof CellEditor) {
            UIComponent inputFacet = child.getFacet("input");
            // multiple
            if (inputFacet instanceof UIPanel) {
                List<Object> values = new ArrayList<>();
                for (UIComponent kid : inputFacet.getChildren()) {
                    if (kid instanceof ValueHolder) {
                        values.add(((ValueHolder) kid).getValue());
                    }
                }
                value = (T) values;
            } else // single
            {
                value = (T) ((ValueHolder) inputFacet).getValue();
            }
        }
    }
    return value;
}
Also used : DataTable(org.primefaces.component.datatable.DataTable) TreeTable(org.primefaces.component.treetable.TreeTable) CellEditor(org.primefaces.component.celleditor.CellEditor) UIComponent(javax.faces.component.UIComponent) UIPanel(javax.faces.component.UIPanel) ArrayList(java.util.ArrayList) UITree(org.primefaces.component.api.UITree) ValueHolder(javax.faces.component.ValueHolder) UIData(org.primefaces.component.api.UIData) DynamicColumn(org.primefaces.component.api.DynamicColumn)

Aggregations

UITree (org.primefaces.component.api.UITree)2 ArrayList (java.util.ArrayList)1 UIComponent (javax.faces.component.UIComponent)1 UIData (javax.faces.component.UIData)1 UIPanel (javax.faces.component.UIPanel)1 ValueHolder (javax.faces.component.ValueHolder)1 DynamicColumn (org.primefaces.component.api.DynamicColumn)1 UIData (org.primefaces.component.api.UIData)1 CellEditor (org.primefaces.component.celleditor.CellEditor)1 DataTable (org.primefaces.component.datatable.DataTable)1 TreeTable (org.primefaces.component.treetable.TreeTable)1