2 Replies Latest reply on Jul 25, 2011 6:28 AM by yasser zairi

    [RESOLVED] Dynamic ComboBox failed

    yasser zairi Newbie

      Hi

      i have a comboBox that i want to populate from my Bean but i got a weird exception andcombo i cannot figure what to fix.

      here is the comboBox :

      ___________________________________________

      <a4j:outputPanel layout="block">

              <h:outputLabel value="Categorie :" />

                    <rich:comboBox defaultLabel="Categorie" >

                          <f:selectItems value="#{ValeursMBean.valeursOptions}"/>

                    </rich:comboBox>

      </a4j:outputPanel>

      _______________________________________________

      here is my Bean :

      ________________________________________________

      package cdvm.surv.web;

       

      import java.io.Serializable;

      import java.util.ArrayList;

      import java.util.Iterator;

      import java.util.List;

       

      import javax.annotation.PostConstruct;

      import javax.faces.model.SelectItem;

       

       

      import org.richfaces.component.html.HtmlScrollableDataTable;

      import org.springframework.beans.factory.annotation.Autowired;

      import org.springframework.context.annotation.Scope;

      import org.springframework.stereotype.Component;

       

       

      import cdvm.surv.model.ValeurRef;

      import cdvm.surv.service.ValeurRefService;

       

      @Component("valeursMBean")

      @Scope("session")

      public class ValeursMBean implements Serializable {

       

          @Autowired

          private transient ValeurRefService valeurefService;

          private transient HtmlScrollableDataTable valeurTable;

       

          private ArrayList<String> valcategories = new ArrayList<String>();

          private List<SelectItem> valeursOptions = new ArrayList<SelectItem>();

          private ArrayList<ValeurRef> valeurs = new ArrayList<ValeurRef>();

       

          private List<ValeurRef> valeurefList;

          private ValeurRef currentvaleur;

       

       

      public ValeursMBean(){

       

              valeursOptions.clear();

              for (ValeurRef val: valeurs) {     

                     valeursOptions.add(new SelectItem(val.getCategorie()));           

              }

       

              valcategories.clear();

              for (ValeurRef val: valeurs) {

                  valcategories.add(val.getCategorie())

             }

       

         }

       

          @PostConstruct

          public void init(){

       

              valeurefList = valeurefService.find();

              currentvaleur=new ValeurRef();  // vider currentvaleur

          }

       

       

          public void update(){

              valeurefService.save(currentvaleur);

              init();

              }      

       

          public void delete(){

              valeurefService.delete(currentvaleur);

              init();

          }

       

          // Getter and Setter...

      ________________________________________________

       

      but i get this error :

      ________________________________________________

       

      java.lang.IllegalArgumentException: Value  of tag <selectItems> attribute is incorrect.

      org.ajax4jsf.util.SelectUtils.getSelectItems(SelectUtils.java:101)

      org.richfaces.renderkit.ComboBoxBaseRenderer.getItems(ComboBoxBaseRenderer.java:95)

      org.richfaces.renderkit.html.ComboBoxRenderer.doEncodeEnd(ComboBoxRenderer.java:578)

      org.richfaces.renderkit.html.ComboBoxRenderer.doEncodeEnd(ComboBoxRenderer.java:626)

      org.ajax4jsf.renderkit.RendererBase.encodeEnd(RendererBase.java:134)

      javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:848)

      org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:281)

      org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)

      org.ajax4jsf.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:78)

      javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:828)

      com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)

      com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)

      javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:828)

      javax.faces.component.UIComponent.encodeAll(UIComponent.java:883)

      javax.faces.render.Renderer.encodeChildren(Renderer.java:137)

      javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:828)

      javax.faces.component.UIComponent.encodeAll(UIComponent.java:883)

      javax.faces.component.UIComponent.encodeAll(UIComponent.java:889)

      com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)

      org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)

      org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)

      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)

      com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)

      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)

      javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)

      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)

      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)

      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)

      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

       

       

       

      i'll be thankful for any kind of suggestions.