jakartaee / expression-language

Jakarta Expression Language
https://eclipse.org/ee4j/el
Other
60 stars 49 forks source link

Support (and how to support) records in BeanELResolver? #201

Closed tandraschko closed 8 months ago

tandraschko commented 1 year ago

As reference: https://github.com/jakartaee/faces/issues/1820

Currently records are not supported in read-access, nor write-access.

I think read-access can be easily added but what about write?

markt-asf commented 1 year ago

A RecordELResolver that sit just before (or just after - I don't think it matters) the BeanELResolver in the default ELResolver seems reasonable.

How do you see write-access working given that Records are intended to be read-only?

tandraschko commented 1 year ago

Sounds good

In theory we could clone it to simulate a write, but thats kinda complex/magic

tandraschko commented 1 year ago

for now we could just throw a exception when trying to write via the ELResolver

markt-asf commented 1 year ago

We can handle attempts to write to a Record the same way we handle attempts to write to a read-only Bean property.

I will note that this means increasing the minimum Java version from 11 to 14 which really means 17 if we want a LTS version. That has a knock-on impact on the Pages API. I don't think either of those is a show-stopper. Just mentioning so everyone is aware and can speak up if they see any issues.

tandraschko commented 1 year ago

+1

pizzi80 commented 10 months ago

Jakarta EE 11 will be Java 21+ and will include Jakarta Persistence 3.2 which has support for java records

https://jakarta.ee/specifications/persistence/3.2/

... Did someone forgot to align the specs with the "web" tier?

tandraschko commented 10 months ago

@markt-asf can we add this readonly resolver for EE11?

markt-asf commented 10 months ago

It is on the TODO list.

hantsy commented 8 months ago

In theory we could clone it to simulate a write, but thats kinda complex/magic

I think it is possible, create a new record instance using the value in the view/request.

markt-asf commented 8 months ago

Records are reads-only. If you want read/write, use a bean.

I have a draft implementation of this. I'll provide a PR shortly.

tandraschko commented 8 months ago

+1 @markt-asf

markt-asf commented 8 months ago

I'll leave the PR (#204) for at least a week for folks to review before thinking about merging.

tandraschko commented 8 months ago

Thanks!