1 Reply Latest reply on Sep 27, 2009 3:27 AM by Walter White

    components.xml - Set of components

    Walter White Novice
      Hi all,

      I would like to configure a component that has several POJOs stored under a certain property.  Essentially, I'm creating a EmailRenderer with support for multiple email senders so you can send from email address 1 and then email address 2 simply by specifying the email address in the template.  In addition, it also supports selecting a locale-specific email template:


      components.xml
      <!--     configure the email senders     -->
           <email:email-renderer>
                <property name="emailSenders">
                     <multiValuedProperty>
                          <email:email-sender email-address="${email.support.emailAddress}" password="${email.support.password}" host="${smtp.host}" port="${smtp.port}" ssl="true"/>
                          <email:email-sender email-address="${email.websiteEmail.emailAddress}" password="${email.websiteEmail.password}" host="${smtp.host}" port="${smtp.port}" ssl="true"/>
                     </multiValuedProperty>
                </property>
           </email:email-renderer>


      EmailRenderer
      @AutoCreate
      @Name("emailRenderer")
      public class EmailRenderer
      {
           public static final String DEFAULT_TEMPLATE_FILE_NAME = "default";
           @Logger
           private Log log;
           @In(create = true)
           private Renderer renderer;
           @In
           private Locale locale;
           private String emailDirectory;
           private Set<EmailSender> emailSenders;
      ...
      }

      Whenever I attempt to determine which email sender to use, the set containing the email senders at that time is null even though I appear to have it configured through components.xml.  I haven't seen any good examples of this, but how do I configure a property such as a set or collection?


      Thanks,
      Walter
        • 1. Re: components.xml - Set of components
          Walter White Novice
          Ok so it turns out, I opened up my Seam book and found the answer: page 98

          <!--     configure the email senders     -->
               <email:email-renderer>
                    <property name="emailSenders">
                         <value>#{supportEmailSender}</value>
                         <value>#{websiteEmailEmailSender}</value>
                    </property>
               </email:email-renderer>

               <component name="supportEmailSender" class="com.walterjwhite.seamCore.email.EmailSender">
                    <property name="emailAddress">${email.support.emailAddress}</property>
                    <property name="password">${email.support.password}</property>

                    <property name="host">${smtp.host}</property>
                    <property name="port">${smtp.port}</property>
                    <property name="ssl">true</property>
               </component>
               <component name="websiteEmailEmailSender" class="com.walterjwhite.seamCore.email.EmailSender">
                    <property name="emailAddress">${email.websiteEmail.emailAddress}</property>
                    <property name="password">${email.websiteEmail.password}</property>

                    <property name="host">${smtp.host}</property>
                    <property name="port">${smtp.port}</property>
                    <property name="ssl">true</property>
               </component>



          Walter