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