Radio Button Quandary

Hi all,

I have a data table with radio buttons in the last column.

The value it's bound to is an Integer.

The selectItems list is Integer, String.

I sometimes get aconversion error. So I wrote a custom converter.

Got the program to fail again, but this time I'm gettingValidation Error: Value is not valid

Whoever answers this question for me... may you have a lifetime full of happiness and good fortune. Please help!

[479 byte] By [Tammy_Ea] at [2007-11-15]
# 1
Which JSF version are you using?
BalusCa at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 2
Version 1.1
Tammy_Ea at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 3
And build? Try installing the latest 1.1_02 from http://javaserverfaces.dev.java.netPlease also post a small complete working and reproduceable code snippet. Like I did here: http://forum.java.sun.com/thread.jspa?threadID=5166678&tstart=0
BalusCa at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 4

JSP

<h:selectOneRadio value="#{varmyRecs.actionCode}"

layout="lineDirection" id="codes" styleClass="std" converter="RadioConverter">

<f:selectItems value="#{varmyRecs.actionCodes}" />

</h:selectOneRadio>

BEAN

Constructor:

setActionCode(action); // action is Integer

actionCodes = new SelectItem[] { new SelectItem(new Integer(1), "Un-Alloc"),

new SelectItem(new Integer(2), "Un-Sched"),

new SelectItem(new Integer(3), "Re-Sched"),

new SelectItem(new Integer(4), "Delete"),

new SelectItem(new Integer(5), "None") };

Now, those beans, as you know, go in a datatable. When I jump to a page with no records (here's where the dropdown comes in - the dropdown filters the records), and then I click to say show me All the records, that's when I got the conversion error.

Now that I've created a converter, now i'm getting a validation error.

CONVERTER:

getAsObject:

if (target == null || target.trim().equals(""))

return target;

Integer integerValue = new Integer(target.trim());

return integerValue;

getAsString:

String value = ((Integer) target).toString();

return value;

Tammy_Ea at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 5
I am sorry to say it again: your code looks fine and I can't reproduce the problem.Try upgrading your JSF version.Which scope have you the managed bean set to? Request or session? This sounds like kind of scoping problem.
BalusCa at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 6
Request scope.OK let's talk upgrading. I'm assuming all I have to do is go to the website you suggested, download the zip file, and then put those jar files in the runtimes... lib folder and then I'm good?
Tammy_Ea at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 7
Yep. Only replace the jsf-api.jar and jsf-impl.jar.
BalusCa at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 8
I replaced jsf-api.jar and jsf-impl.jar and it totally did nothing. #:(What platform are you using?
Tammy_Ea at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...