4 Replies Latest reply on May 12, 2011 3:34 PM by Erik Doetsch

    Factory and static

    Erik Doetsch Newbie

      This worked in JBoss 4.2.3/Seam 2.1.1 but not flunks in 5.1/2.2.1


      This was coded by a previous developer and I am wondering if I am simply do not understand @Factory or if it worked differently previously. This dropdown is giving me the error:
      Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(startDateLimit)


      I left the previous developer's comment in as it implies perhaps something strange was done in earlier versions.




                      <ui:define name="input">
                        <h:selectOneMenu id="startDateLimit" value="#{contractSearchData.startDateLimit}" >
                           <s:selectItems value="#{dateLimits}" var="startDateLimit" label="#{startDateLimit}" />
                        </h:selectOneMenu>      
                      </ui:define>
      
      @Name("contractSearchData")
      @Scope(ScopeType.CONVERSATION)
      public class ContractSearchData extends SessionAwareObject implements Serializable {
      
         // Static var goes into one of the Seam Contexts??
         // When referencing a static var on JSF page, use its name as is, without reference to the component itself,
         // like "dateLimits", not "contractBean.dateLimits".
         // Have to use @Factory for Seam to inject a static var, 
         // because it may need it, like in this case before seam component itself is needed.
         public final static String [] dateLimits = new String[] {"On or Before", "On", "On or After"};
       
         /**
          * @return drop down values for selecting dates
          */
         @Factory("dateLimits")                                                              
         public static String[] getDateLimits() {
            return dateLimits;
         }
      
      }