Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Rapster opened this issue Aug 4, 2023 · 5 comments
Closed

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

Rapster opened this issue Aug 4, 2023 · 5 comments

Comments

@Rapster
Copy link

Rapster commented Aug 4, 2023

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
Copy link
Contributor

Original Discussion in PrimeFaces: primefaces/primefaces#10426

@pizzi80
Copy link
Contributor

pizzi80 commented Aug 10, 2023

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
Copy link
Contributor

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

@pizzi80
Copy link
Contributor

pizzi80 commented Aug 11, 2023

😃 👍 👍

@BalusC
Copy link
Contributor

BalusC commented Sep 9, 2023

2.3.21 and 4.0.4 have been released with the improvement.

@BalusC BalusC closed this as completed Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants