title: Validation error value is not valid
body: <p>I know this is a common error, and that there is a lots of questions about it, but I must create new one.</p>
  
  <p>Here is my jsf page:</p>
  
  <pre><code>&lt;h:form id="clientCreatingForm"&gt;
      &lt;p:selectOneMenu id="city" value="#{kkmBean.client.address.city}" style="width: 263px;" 
            converter="cityConveter" required="true" requiredMessage="You must choose one city"&gt;
            &lt;f:selectItems value="#{kkmBean.cityList}" var="city" itemLabel="#{city.cityName}" itemValue="#{city.cityID}"/&gt;
       &lt;/p:selectOneMenu&gt;
  
  
       &lt;p:commandButton value="Save client" type="button" onclick="confirm.show()" style="margin-top: 20px; margin-left: 30px; width: 180px;" /&gt;
       &lt;p:commandButton value="Reset fields" type="reset" style="margin-top: 20px; margin-left: 30px; width: 180px;"/&gt;
  
            &lt;p:confirmDialog message="Are you sure, you want to save client?" 
                 header="Save client" severity="info" widgetVar="confirm"&gt;
  
                 &lt;p:commandButton value="Yes, I am sure." oncomplete="confirm.hide()" 
                                           action="#{kkmBean.saveClient}" update=":warnings" style="font-size: 12px;"/&gt;
                 &lt;p:commandButton value="No, I don't!" onclick="confirm.hide()" type="button" style="font-size: 12px;"/&gt;
            &lt;/p:confirmDialog&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>Here is managed bean:</p>
  
  <pre><code>@ManagedBean(name = "kkmBean")
  @SessionScoped
  public class CreatingClientManager implements Serializable {
  
  /** Creates a new instance of CreatingClientManager */
  public KreiranjeKorisnikaManager() {
      client= new Client();
      client.setAddress(new Address());
      cityList = new LinkedList&lt;City&gt;();
      cityList = Communication.getInstance().getCitySessionBeanRemote().getCities();
    }
  
  private Client client;
  private List&lt;City&gt; cityList;
  
  public String startCreatingClent() {
  
      return "creating-client";
    }
  
  /**
   * @return the client
   */
  public Klijent getClient() {
      return client;
    }
  
  /**
   * @param client the client to set
   */
  public void setClient(Client client) {
      this.Client = client;
    }
  
  /**
   * @return the cityList
   */
  public List&lt;Grad&gt; getCityList() {
      return cityList;
    }
  
  /**
   * @param cityList the cityList to set
   */
  public void setCityList(List&lt;City&gt; cityList) {
      this.cityList = cityList;
    }
  
  public String saveClient() {
      System.out.println("i am in saveClient method");
      String message = Communication.getInstance().getClientSessionBeanRemote.saveClient(client);
      FacesContext context = FacesContext.getCurrentInstance();
      kontekst.addMessage(message, new FacesMessage(FacesMessage.SEVERITY_INFO, "Success: ", message));
      return null;
    }
  }
  </code></pre>
  
  <p>And finally converter:</p>
  
  <pre><code>   @FacesConverter(forClass=City.class, value="cityConverter")
     public class CityConverter implements Converter {
  
     @Override
     public Object getAsObject(FacesContext context, UIComponent component, String value) {
        Integer cityID = Integer.valueOf(value);
        CreatingClientManager kkm = (CreatingClientManager) ((HttpSession)context.getExternalContext().getSession(true)).getAttribute("kkmBean");
        List&lt;Grad&gt; cityList = kkm.getCityList();
        for (int i = 0; i &lt; cityList.size(); i++) {
            City city = cityList.get(i);
            if(city.getCityID().equals(cityID)) {
                System.out.println(city.getCityName());
                return city;
            }
        }
        return null;
    }
  
    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return value.toString();
    }
  }
  </code></pre>
  
  <p>Of course the problem is in selectOneMenu. When I submit form, i got this annoying error.</p>
  
  <p>I was debugging converter and the line before return grad, i print grad.getImeGrada() and everything is fine, the name (Ime) of found city (grad) is printed. Am I missing something?</p>
  
  <p>p.s. Sorry on my English, I hope that you understand what is my problem.</p>
  
  <p>Almost forgot to mention that i override equals and hashCode methods, and i am sure it is ok.</p>