Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JBoss User Help »

[jboss-user] [JBoss Seam] - Re: selectOneMenu and selectItems
 problem

scott.stark@jboss.org

2007-07-11


"pete.muir@(protected)?


Hi,
message from h:messages is:

"value is not valid"

but why ?

the Converter class:


| @Name("CompanyConverter")
| @Converter
| public class CompanyConverter implements javax.faces.convert.Converter, Serializable {
|
|  @Logger
|  private Log log;
|
|  @In(required = false)
|  List<Company> companies;
|
|  /*
|   * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext,
|   *    javax.faces.component.UIComponent, java.lang.String)
|   */
|  public Object getAsObject(FacesContext arg0, UIComponent arg1, String string) throws ConverterException {
|    if (string == null || string.length() == 0) {
|      return null;
|    }
|
|    long id = Long.valueOf(string).longValue();
|    log.info("[getAsObject] string -> " + string);
|    log.info("[getAsObject] id -> " + id);
|    log.info("[getAsObject] companies -> " + companies);
|    if (companies != null) {
|      for (Company referenceData : companies) {
|        if (referenceData.getId() == id) {
|          log.info("[getAsObject] returning -> " + referenceData);
|          return referenceData;
|        }
|      }
|    }
|    log.info("[getAsObject] returning -> null" );
|    return null;
|  }
|
|  /*
|   * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext,
|   *    javax.faces.component.UIComponent, java.lang.Object)
|   */
|  public String getAsString(FacesContext arg0, UIComponent arg1, Object obj) throws ConverterException {
|    log.info("[getAsString] obj -> " + obj);
|    if (obj == null) {
|      return null;
|    }
|    Company company = (Company) obj;
|    log.info("[getAsString] company -> " + company);
|    return String.valueOf(company.getId());
|  }
|
| }
|

Both methods return not null values.

Any idea ?

Thanks,
Mttu


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4062936#4062936

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4062936
_______________________________________________
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.