1

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.

seenukarthi
  • 8,241
  • 10
  • 47
  • 68
Eiten
  • 73
  • 8
  • [This one](https://github.com/primefaces-extensions/showcase/blob/master/src/main/java/org/primefaces/extensions/showcase/util/ShowcaseUtil.java)? – WoAiNii Mar 19 '23 at 16:06
  • No, I check this before. There is no method: getPropertyValueViaReflection. That is the main issue that I have with this Class – Eiten Mar 19 '23 at 16:10

1 Answers1

1

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.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102