myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Robinson" <andrew.rw.robin...@gmail.com>
Subject Re: type problems with t:selectOneMenu / f:selectItem
Date Wed, 25 Jul 2007 14:56:25 GMT
If you are using facelets, you could create EL casting functions. Example:

public static Integer getInteger(Object value) {
  if (value == null) {
    return null;
  } else if (value instanceof Number) {
    return new Integer(((Number)value).intValue());
  } else {
    try {
      return Integer.parseInt(value.toString());
    } catch (NumberFormatException ex) {
      return "NaN";
    }
  }
}

// Repeat for Double, Float, Long, etc.

then use:

<f:selectItem itemLabel="2009" itemValue="#{my:getInteger(2009)}" />

On 7/25/07, Svilen Ivanov <svilen.ivanov@sirma.bg> wrote:
> Marcus Beyer wrote:
> [...]
>
> >>
> >> Please see the WIKI as it is documented there.
> >
> > Where? <http://wiki.apache.org/myfaces/>? I cannot find anything about it.
>
> Check this wiki page:
> http://wiki.apache.org/myfaces/Tomahawk_1%2e1%2e4_to_1%2e1%2e5
>
> Regards
>
> --
> Svilen Ivanov
> http://svilen-online.blogspot.com
>
> There is no dark side of the moon really.
> Matter of fact it's all dark.
>

Mime
View raw message