Eiten
Eiten

Reputation: 139

PrimeFaces ShowcaseUtil class in PF v12 still available?

I can not to find class ShowcasesUtil, that is use to filters, sorting of PrimeFaces LazySorting, LazyFiltering. Example below:

public int compare(Customer customer1, Customer customer2) {
        try {
            Object value1 = ShowcaseUtil.getPropertyValueViaReflection(customer1, sortField);
            Object value2 = ShowcaseUtil.getPropertyValueViaReflection(customer2, sortField);

            int value = ((Comparable) value1).compareTo(value2);

            return SortOrder.ASCENDING.equals(sortOrder) ? value : -1 * value;
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

Found information that it is a part of PrimeFaces Extensions: primefaces.extension.showcase. I try with 11.0.6 but still can not find this class in package. How to use it?

I try find it in PrimeFaces Extensions showcase 11.0.6.

Upvotes: 1

Views: 898

Answers (1)

Jasper de Vries
Jasper de Vries

Reputation: 20158

Just look in the PrimeFaces GitHub repository. You can find the file in both the 11.0.0 tag and the 12.0.0 tag:

https://github.com/primefaces/primefaces/blob/12.0.0/primefaces-showcase/src/main/java/org/primefaces/showcase/util/ShowcaseUtil.java This is the method:

public static final Object getPropertyValueViaReflection(Object o, String field)
                throws ReflectiveOperationException, IllegalArgumentException, IntrospectionException {
    return new PropertyDescriptor(field, o.getClass()).getReadMethod().invoke(o);
}

You can simply copy it to your project.

Upvotes: 2

Related Questions