JSF 2.0: Passing a composite component attribute to an internal composite component

I have the following case:

<cc:interface> <cc:attribute name="someValue" /> </cc:interface> <cc:composite> <x:someComponent> <span>#{cc.attrs.someValue}</span> </x:someComponent> </cc:composite> 

Thus, inside my composite component, I call some other composite component and try to pass the parameter set to the master component to the internal composite component.

This fails because inside the x:someComponent instead of the implicit cc object, it refers to this x:someComponent .

The workaround is to create a temporary field for x:someComponent , so this can be achieved as:

 <x:someComponent passthroughField="#{cc.attrs.someValue}"> <span>#{cc.attrs.passthroughField}</span> </x:someComponent> 

However, it is very ugly and uncomfortable.

Any other solutions to this problem?

+4
source share
1 answer

One way to hack this is to use ui:param as in:

 <ui:param name="foo" value="cc.attrs.someValue" /> <x:someComponent> <span>#{foo}</span> </x:someComponent> 

See another question .

+1
source

Source: https://habr.com/ru/post/1334082/


All Articles