faces icon indicating copy to clipboard operation
faces copied to clipboard

Support Record as Back Bean property

Open hantsy opened this issue 1 year ago • 9 comments

Assume we have a backing bean like this.

@ViewScoped
@Named("todosHome")
class TodosHome{
   private TodoForm form;

   // setters and getters.
}

And TodoForm here is a record.

record TodoForm(String title){}

In the faceslets xhtml page, it should can be bound to a html form.

<input jsf:value="#{todosHome.form.title}/>

hantsy avatar Jun 12 '23 15:06 hantsy

Sounds good. Let's see what we can do to support this. My gut feeling says it's an Expression Language issue and not directly something Faces does.

arjantijms avatar Jun 12 '23 15:06 arjantijms

I am not sure if this is just an EL binding work.

hantsy avatar Jun 12 '23 15:06 hantsy

Oh well, we can investigate it here first and see what's needed.

arjantijms avatar Jun 12 '23 15:06 arjantijms

I think that must be implemented in BeanElResolver in el-specs

tandraschko avatar Jun 12 '23 16:06 tandraschko

It's indeed in EL. See also https://balusc.omnifaces.org/2020/11/using-java-14-records-in-jsf-via-eclipse.html

BalusC avatar Jun 18 '23 16:06 BalusC

It's indeed in EL. See also https://balusc.omnifaces.org/2020/11/using-java-14-records-in-jsf-via-eclipse.html

It can not bind values from a HTML form.

There is no copy method like the Kotlin data class, ideally when set a new value, create a new instance and copy values from the old instance.

hantsy avatar Jun 19 '23 01:06 hantsy

create a issue in EL specs

tandraschko avatar Jun 26 '23 09:06 tandraschko

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?

pizzi80 avatar Sep 05 '23 12:09 pizzi80

thats up to EL

tandraschko avatar Sep 05 '23 12:09 tandraschko

Currently already implemented in EL 6.0 as per https://github.com/jakartaee/expression-language/issues/201

BalusC avatar Sep 02 '24 17:09 BalusC