5

We can access the Composite Component attribute values (defiled in the interface section), in the implimentation like #{cc.attrs.attributeName}

How can we access this value in the backing component?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
siva636
  • 16,109
  • 23
  • 97
  • 135

1 Answers1

7

It's just available inside any of the methods by the inherited getAttributes() method which returns a Map<String, Object> with the attribute name as map key and attribute value as map value.

Bar bar = (Bar) getAttributes().get("bar");
// ...
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I want to access the attribute of the Composite Component in the backing bean of that Composite Component itself. The backing bean will use the attribute for implementing the Composite Component. (I hope you described above how to access the attribute of the Composite Component in the backing bean of the page which uses the Composite Component) – siva636 Aug 01 '11 at 12:51
  • So, you're talking about the backing `UIComponent`? That's not a backing bean... Just call the inherited `getAttributes()` method. See also our composite component wiki page: http://stackoverflow.com/tags/composite-component/info – BalusC Aug 01 '11 at 12:52
  • This is exactly what I have been looking for. The link you gave is also very useful. Thanks a lot BalusC. – siva636 Aug 01 '11 at 13:36
  • You're welcome. I've updated your question and my answer accordingly to reflect what you really meant and what you really need. – BalusC Aug 01 '11 at 13:38