7

I create a composite component like this:

<cc:interface>        
    <cc:attribute name="value" 
                  required="true" />
    <cc:attribute name="rendered"
                  displayName="True to render"
                  default="true" />
</cc:interface>

When I invoke this component, I get an IllegalArgumentException. I can changed the rendered name to something else (like doIt) and then it works.

Is the rendered attribute reserved somehow? I want my composite component to look like "regular" JSF components.

This is with Mojarra.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
AlanObject
  • 9,613
  • 19
  • 86
  • 142
  • 1
    In the future, you don't need to explicitly tag `[mojarra]` if the problem is not Mojarra specific. You would have exactly the same problem when you tried for example MyFaces. Just mentioning JSF impl/version in the question is sufficient. – BalusC Nov 12 '11 at 22:51
  • I put Mojarra there because I thought it might be a Mojarra bug. But point taken. – AlanObject Nov 13 '11 at 01:32

1 Answers1

16

Composite components extend UINamingContainer which in turn extend UIComponentBase which in turn already definies the id and rendered attributes. You don't need to specify them yourself. Just remove the <cc:attribute name="rendered">. If you specify the rendered attribute on the composite component tag, then it'll be interpreted and applied on the composite component itself.

If you intend to render specific children of the composite, then better invent a different attribute name. For example, renderSomeChild.

The Student
  • 27,520
  • 68
  • 161
  • 264
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • When editing the component in the NetBeans 7.1 editor, it considers the **rendered** attribute to be an error when it is not defined by a **cc:attribute** element. Is that a Netbeans bug? – AlanObject Nov 13 '11 at 01:34
  • Sorry, I have not really used Netbeans for more than 5 minutes. It works fine that way in Eclipse. – BalusC Nov 13 '11 at 02:57
  • 2
    As much sense as you answer makes, it have the same problem in Eclipse: The "rendered" attribute of my own composition component is underlined and marked as an unknown element. JSF 2.1.24, Eclipse 3.7.2 with JBOSS JSF tools. – alfonx Oct 30 '12 at 19:50