omnifaces / optimusfaces

Utility library for OmniFaces + PrimeFaces combined

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LazyPagedDataModel ordering should be exposed (or at least constructor should be public or protected)

adets opened this issue · comments

commented

As of now LazyPagedDataModel (and consequently NonLazyPagedDataModel) have package-private constructors which make it impossible to inherit from them unless one wants to use the same package name. I guess the intention is to hide the implementation details and just construct the models using builders but there is one important omission with the PagedDataModel.Builder - it allows to pass criteria map but doesn't allow to pass ordering map - it internally creates a NEW map from orderBy clauses. The end result is that if one wants to programmatically modify criteria then this is just a question of modifying the data inside the criteria map, however, if one wants to modify the ordering then this is impossible as there is no external access to ordering map.

Please consider adding something like this to the Builder:

	public Builder<E> ordering(LinkedHashMap<String, Boolean> ordering) {
            if (!this.ordering.isEmpty()) {
                throw new IllegalStateException("Ordering is already set");
            }
		    
            this.ordering = ordering;
            return this;
	}

Or, alternatively, change visibility of the constructor to allow for extensibility. Or both. :-)

Point taken.