eclipse-ee4j / mojarra

Mojarra, a Jakarta Faces implementation
Other
158 stars 108 forks source link

UIData: return static empty data model if value is null #5296

Closed Rapster closed 10 months ago

Rapster commented 11 months ago

Macro optimization:

In UIData#getDataModel, if value is null, a new instance of an empty datamodel will be returned, instead reuse a static immutable instance.

For example:

private static final DataModel EMPTY_DATA_MODEL = new ListDataModel(Collections.emptyList());

@Override
protected DataModel getDataModel() {
  if (model != null) {
    return (model);
  }

  Object current = getValue();
  if (current == null) {
    setDataModel(EMPTY_DATA_MODEL);
  }
  // etc.
}
melloware commented 11 months ago

Original Discussion in PrimeFaces: https://github.com/primefaces/primefaces/pull/10426

pizzi80 commented 11 months ago

Why you didn't create a PR ?

If you can't I'll create one but it's basically a copy/paste of your code ...

melloware commented 11 months ago

I think he was going on Holiday so PR would be great @pizzi80 !

pizzi80 commented 11 months ago

:smiley: :+1: :+1:

BalusC commented 10 months ago

2.3.21 and 4.0.4 have been released with the improvement.