Dynamic attributes nesting within composite components

202 views Asked by At

I am struggling with nesting dynamic JSF attributes within composite components.

Let us imagine following structure on client side:

class BackingBean{
    Animal animal;
}

class Animal {
    Type type;
}

class Type{
    String name;
}

On the view side I can reach to the nested fields using . character:

#{backingBean.animal.type.name}

In that case, everything works like a charm. Problem emerges when I want to rewerite it into composite component and represent nested fields as a separate attributes:

<cc:interface>  
    <cc:attribute name="mainAttribute"/>
    <cc:attribute name="nestedAttribute"/>
    <cc:attribute name="valuesProviderService"/>
</cc:interface>

<cc:implementation>
    <f:selectItems value="#{cc.attrs.valuesProviderService.findAnimals}" 
    var="animal" itemValue="#{animal}" itemLabel="#{$HERE_IS_NESTING$}" />
</cc:implementation>

I tried a variety of approaches, but I guess my current knowledge is not enough to solve it.

I tried to use nesting with [ character like:

itemLabel="#{animal[cc.attrs.mainAttribute[cc.attrs.nestedAttribute]]}"

also tried with c:set

<c:set var="main" value="#{cc.attrs.mainAttribute}" />
<c:set var="nested" value="#{cc.attrs.nestedAttribute}" />   

and then use it itemLabel="#{animal.main.nested}"

I hope you know what I want to achieve. Can you help me out a bit here?

0

There are 0 answers