1

I have looked into the possibilities of facelet tag files, custom components, custom renderers, but couldn't figure this out. Highly appreciate if someone can direct me in a possible solution. Here's what I need to do

I have a lot of label, input, message sections in my views. So what what basically want to is to avoid adding 3 tags and achieve it by using 1 custom tag such as

<my:input value="#{customerBean.customer.name}"/>

I already know the label of the field from the customer entity field annotation like

@Field(label = "Customer Name")
private String name;

My question is, how can I get the entity value from the value expression customerBean.customer.name. So that I can find out the entity field annotation label via reflection. I cannot always depend on the literal name "customer" as it could also be "customerBean.record.name" or something similar

I also want to avoid passing the entity name as an attribute.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • Not 100% sure how your component internally looks and works, but I think you need a backingbean for the composite component like in https://stackoverflow.com/questions/15923078/backing-bean-in-composite-component-is-recreated-on-every-request and http://balusc.omnifaces.org/2013/01/composite-component-with-multiple-input.html In it you can get the value of the resolved EL from the value attribute and use it in reflection. – Kukeltje Jun 07 '18 at 16:43
  • The component is a simple input with a backing bean for the value. What I simply need is to automatically add a label to it depending on the value-expression of the input. Ex: value expression says customerBean.record.name, the view should automatically know this is referring to the "customer" entity's name field thus fining out it's intended label name (via entity field annotation using reflection) – Cadrian Brown Jun 08 '18 at 05:15
  • Also, I don't want to use a composite component. Prefer a fecelets tag, custom component or a tag handler whatever that would allow me to change the component tree to make use of the value-expression of an existing component and add a new label component – Cadrian Brown Jun 08 '18 at 05:17

0 Answers0