0 Replies Latest reply on May 27, 2011 4:17 PM by Michael Hughes

    rich:picklist and converter not displaying results

    Michael Hughes Newbie

      Working on an app that takes various results from picklists and input boxes and places them in a dataTable. My picklists that contain Character data work perfectly. However, I have one picklist that uses data of a short type and my converter doesn't seem to pick up my code. The problem may also lie in my Expression Language statement but I'm not sure. I'm using JBoss 4.2.2GA, Seam 2.1.2GA, RichFaces 3.3.3, and JSF 1.2.

       

      My xhtml:

       

       

      <rich:pickList 
                                    id="controllerPickList"
                                    value="#{sortDataList.controllerListAssigned}"
                                    converter="#{sortDataList.controllerConverter}"
                                    switchByClick="true"                     
                                    label="Controller"
                                    showButtonsLabel="false" 
                                    sourceListWidth="125" 
                                    targetListWidth="125">
      
                                            <f:selectItem  
                                                      itemLabel="#{messages['Company 1']}" itemValue="1" value="#{minMax.controller}" />
                                            <f:selectItem 
                                                      itemLabel="#{messages['Company 2']}" itemValue="29" value="#{minMax.controller}" />
                                            <f:selectItem  
                                                      itemLabel="#{messages['Company 3']}" itemValue="14" value="#{minMax.controller}" />
                                            <f:selectItem  
                                                      itemLabel="#{messages['Company 4']}" itemValue="11" value="#{minMax.controller}" />
                                            <f:selectItem 
                                                      itemLabel="#{messages['Company 5']}" itemValue="7" value="#{minMax.controller}" />
                                            <f:selectItem  
                                                      itemLabel="#{messages['Company 6']}" itemValue="200" value="#{minMax.controller}" />
                                  </rich:pickList>        
                                </h:column>
      

       

      My SortDataList.java which includes the Expression Language:

       

      @Name("sortDataList")
      public class SortDataList extends EntityQuery<PersonData> implements Serializable
      {
                private static final long serialVersionUID = 1L;
                private List<String> controllerListAssigned = new ArrayList<String>();
                private ControllerConverter controllerConverter;
                private PersonData personData;
      
                private static final String EJBQL = "Select personData From PersonData personData";
      
                private static final String[] RESTRICTIONS =
                {                     
                    "personData.controller in (#{controllerListAssigned.size() > 0 ? " 
                        + "controllerListAssigned : null})", 
                };
      
                public MinMax minMax;
      
                public MinMax getMinMax() 
                {
                          return minMax;
                } 
      
                public void setminMax(MinMax minMax) 
                {
                          this.minMax = minMax;
                } 
      
                public SortDataList()
                { 
                          personData = new PersonData();
                          personData.setId(new PersonDataId());
                          minMax = new MinMax();
                          setEjbql(EJBQL);
                          setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
                          setMaxResults(Integer.valueOf(250));
                }
      
                public PersonData getPersonData() {
                          return personData;
                } 
      
                public void setPersonData(PersonData personData) {
                          this.personData = personData;
                } 
      
                // Fix for Count Query with composite id
                @Override 
                protected String getCountEjbql()
                {
                          setUseWildcardAsCountQuerySubject(true);
                          return super.getCountEjbql();
                }
      
                public List<SelectItem> getControllerList()
                {
                          return controllerList;
                }
      
                public void setControllerList (List<SelectItem> controllerList)
                {
                          this.controllerList = controllerList;
                }
      
                public List<String> getControllerListAssigned()
                {
                          return controllerListAssigned;
                }
      
                public void setControllerListAssigned(List<String> controllerListAssigned)
                {
                          this.controllerListAssigned = controllerListAssigned;
                }
      
                public void setControllerConverter(ControllerConverter controllerConverter) {
                          this.controllerConverter = controllerConverter;
                } 
      
                public ControllerConverter getControllerConverter() {
                          return controllerConverter;
                } 
      
      }
      
      

       

      My ControllerConverter.java:

       

      import com.crinet.vapmpg.entity.PersonData; 
      
      public class ControllerConverter implements Converter 
      {
                @SuppressWarnings("rawtypes")
                private Map choiceMap;
      
                public String getAsString(FacesContext context, UIComponent component, Object value)
                { 
                          if(value == null)
                                    return null;
      
                          PersonData personData = (PersonData)value;
                          String label = String.valueOf(personData.getController());
      
                          return label;
                }
      
                public Object getAsObject(FacesContext context, UIComponent component, String label)
                {
                          if(label == null || label.length()==0)
                                    return null;
      
                          return choiceMap.get(label);
                }
      
                /**
                 * @param choiceMap the choiceMap to set
                 */
                @SuppressWarnings("rawtypes")
                public void setChoiceMap(Map choiceMap) {
                          this.choiceMap = choiceMap;
                }
      }
      
      

       

      And finally, my PersonData.java

       

       

      @Entity
      @Table(name = "GNWPERSONDATA")
      public class PersonData implements java.io.Serializable
      {
                private static final long serialVersionUID = 1L; 
      
                private PersonDataId id; 
      
                private String shortName;
                private Character status;
                private short controller;
      
                public PersonData()
                {
                }
      
                public PersonData(PersonDataId id, String shortName, Character status,  
                  short controller)
                {
                          super();
                          this.id = id;
                          this.shortName = shortName;
                              this.status = status;
                          this.controller = controller;
                }
      
                @NotNull
      
                public PersonDataId getId()
                {
                          return this.id;
                }
      
                public void setId(PersonDataId id)
                {
                          this.id = id;
                }
      
                @Column(name = "SHORTNAME", nullable = false, length = 20)
                @NotNull
                @Length(max = 20)
                public String getShortName()
                {
                          return this.shortName;
                }
      
                public void setShortName(String shortName)
                {
                          this.shortName = shortName;
                }
      
                @Column(name = "STATUS", length = 1)
                public Character getStatus()
                {
                          return this.status;
                }
      
                public void setStatus(Character status)
                {
                          this.status = status;
                }
      
                @Column(name = "CONTROLLER", nullable = false, precision = 4, scale = 0)
                public short getController()
                {
                          return this.controller;
                }
      
      
                public void setController(short controller)
                {
                          this.controller = controller;
                }
      }
      
      

       

       

      Any help is greatly apprectiated!