Hi,

there is still a little problem with that. #{0} is a Long value, so the getter/setter needs be a also a Long and not an Integer.
I don't know, if in EL there is something like a "cast" operator...

Regards,

Udo

Am 22.04.10 18:20, schrieb Volker Weber:
Hi Michael,

(btw yes i work together with Dirk Fangohr. sorry for the delay, was a
bit busy last Friday)

the problem is you has int as value in getActive() but String in select items.

Try
        <tc:selectItem itemValue="#{2}" itemLabel="active"/>
        <tc:selectItem itemValue="#{1}" itemLabel="suspended"/>
        <tc:selectItem itemValue="#{0}" itemLabel="inactice"/>

you don't need a converter!


Regards,
     Volker

2010/4/21 Michael Kakuschky<kakusc...@elbe-net.de>:
Hello,

I have a strange problem selecting the correct item of tx:selectOneChoice
boxes if the  itemValue of the tc:selectItem item is an Integer.

Storing the selected values works fine as aspected. I will find the correct
values in mybackend database

What does not work is that after rerendering the correct value is selected.
If in my example the MyController.active Integer attribute has a value of 1
"suspended" should be selected. But it's always the first value of the
tc:selectItem elements selected.

I tried already to use a converter because  I guessed that  there is an
conversion problem between Integer  and String but it does not help.

If the selectItem bind to a String  it works fine (sure without the
integerConverter). With the tomahawk h:selectOneMenu component it works also
with Integers.

Knows anybody how to solve this problem for tobago to use an Integer as
value attribute?

<tc:cell>
    <tx:selectOneChoice value="#{myController.active}" label="active"
  converter="integerConverter">
        <tc:selectItem itemValue="2" itemLabel="active"/>
        <tc:selectItem itemValue="1" itemLabel="suspended"/>
        <tc:selectItem itemValue="0" itemLabel="inactice"/>
    </tx:selectOneChoice>
</tc:cell>

public class MyController{
   private Integer active = 1;

   public Integer getActive() {
       return active;
   }
   public void setActive(Integer active) {
       this.active = active;
   }
}

public class IntegerConverter  implements Converter {

  public Object getAsObject(FacesContext context, UIComponent component,
String value) throws ConverterException {
   return Integer.getInteger(value);
  }

public String getAsString(FacesContext context, UIComponent component,
Object value) throws ConverterException {
   if (value instanceof Integer) {
     return ((Integer) value).toString();
   }
   return "";
  }
}

Thanks and best regards

Michael



Reply via email to