0 Replies Latest reply on May 24, 2007 10:28 PM by hurzeler

    selectOneMenu with s:convertEntity and noSelectionLabel does

    hurzeler

      Hello there,

      I got a simple menu using

      <ice:selectOneMenu id="#{messages['region']}" styleClass="selectTagMenu" value="#{siteList.selectedRegion}"
       partialSubmit="true">
      <s:selectItems value="#{regions.resultList}" var="region"
       label="#{region.name}" noSelectionLabel="Select..."/>
      <s:convertEntity />
      </ice:selectOneMenu>
      <ice:commandButton value="#{messages['reset']}"
       action="#{siteList.reset}" /
      


      This is all wonderful and the list is displayed. However if I don't select anything (as it is optional) and click the command button the value of the selectOneMenu is "Select..." and the EntityConverter gets confused in

       public Object getAsObject(FacesContext facesContext, UIComponent cmp, String value) throws ConverterException
       {
       if (value == null)
       {
       return null;
       }
       Integer key = new Integer(value);
       Class clazz = EntityConverterStore.instance().getClass(key);
       Object id = EntityConverterStore.instance().getId(key);
       return loadEntityFromPersistenceContext(clazz, id);
       }
      


      the value is a string and not null. Hence
      new Integer(value)
      fails.

      Am I missing something or is there an easy fix short from not using entities directly or leaving out the noSelectionLabel?

      Your help is appreciated.