SelectOneRadio with converter and commandButton with immediate

Hi,

Given the following jspx:

<h:selectOneRadio value="#{bean.currentCar}" required="true">

<f:selectItems value="#{bean.carList}"/>

<f:converter converterId="carConverter"/>

</h:selectOneRadio>

<h:commandButton value="Do it" immediate="true" action="#{bean.doItAction}"/>

When a value is selected and the button is pressed the selected value will disappear. This happens because the immediate attribute on the commandButton prevents that the Converter will be called. Of course when the immediate attribute on the selectOneRadio is set to true the selected value will be correclty displayed (but you dont want that because then validation will happen too).

Why is it that if you use a SelectOneRadio with String values the value is still selected but when you use an object and a converter not?

[1057 byte] By [Jerry_a] at [2007-11-27 8:33:40]
# 1

I got it, its a problem with my Converter implementation

public String getAsString(FacesContext facesContext,

UIComponent uiComponent, Object value) {

if (value instanceof Car) {

return ((Car)value).getId().toString();

}

else if (value instanceof String) {

return (String)value;

}

return null;

}

The value can be a String in this circumstances.

Jerry_a at 2007-7-12 20:29:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...