3 Replies Latest reply on Mar 27, 2009 7:18 PM by norman

    Dynamically add component definition

      How can I dynamically add a component definition to components.xml. I've defined several similar components using the <component> tag in components.xml, and it's now getting difficult to maintain. Is there a way to add these definitions programmatically?

      If my component is as follows in components.xml, how can I add the same definition programmatically?

      <component class="MyClass" name="myName">
        <property name="myProp">myValue</property>

        • 1. Re: Dynamically add component definition

          In theory, it would be possible to add Component definition instances programmatically.  I mean, all seam is doing is translating the XML to component definitions.  It's not something we encourage as a public API, and there might be some hot deploy issues.  But, I don't see any reason it wouldn't work.

          • 2. Re: Dynamically add component definition

            Are you suggesting its currently possible to do within Seam, or that it's a worthwhile feature request?

            If it's currently possible, I'm not sure how to do it - I noticed that Component currently only has one public constructor not labelled 'for testing' in the source code, and that it's called from the Init class. However, I can't tell from that constructor how I'd set all the properties as I described in the above post.

            • 3. Re: Dynamically add component definition

              I'm suggesting it's feasible enough that it might be worth digging through the code to figure out and give it a try.  If you aren't comfortable enough with Seam to do that, then you should assume it's not possible.