• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2879
  • Last Modified:

RadioButtonGroup validation

I get the error:

Error #1069: Property selectedItem not found on mx.controls.RadioButtonGroup and there is no default value.

Flex doesn't seem to have anything specific for radio buttons. So how would I handle this? The default value for report.attended = -1


<mx:NumberValidator source="{attended}" property="selectedItem" allowNegative="false"/>
 
<mx:FormItem required="true" verticalGap="0" enabled="{editMode}">
	<mx:RadioButtonGroup id="attended" selectedValue="{report.attended}"/>
	<mx:RadioButton groupName="attended" label="Yes"  value="1"/>
	<mx:RadioButton groupName="attended" label="No"  value="0"/>
</mx:FormItem>

Open in new window

0
hallikpapa
Asked:
hallikpapa
  • 4
  • 4
1 Solution
 
Fuzzy_Logic_Commented:
change:

 property="selectedItem"

to

 property="value"

Although I can't see why you need a NumberValidator since the value will either be 1 or 0.
0
 
Fuzzy_Logic_Commented:
sorry that should be

property="selectedValue"
0
 
hallikpapaAuthor Commented:
I added just that one validator, and I got "cannot access null property or reference"

I don't need numbervalidator, just trying different options
0
Get Cisco Certified in IT Security

There’s a high demand for IT security experts and network administrators who can safeguard the data that individuals, corporations, and governments rely on every day. Pursue your B.S. in Network Operations and Security and gain the credentials you need for this high-growth field.

 
Fuzzy_Logic_Commented:
see amendment above.
0
 
hallikpapaAuthor Commented:
Sorry, I should have included I entered selectedValue
0
 
hallikpapaAuthor Commented:
This is what it looks like now, and it still gives me an error:
private function _validate():void
{
        if(Validator.validateAll(promoCodeValidators).length > 0)
	{
		var err:ValidationResultEvent;
        var errorMessageArray:Array = [];
        var validatorErrorArray:Array = Validator.validateAll(promoCodeValidators);
        for each (err in validatorErrorArray) 
        {
            //ERROR HERE ONLY FOR THE RADIO BUTTON GROUP
            var errField:String = FormItem(err.currentTarget.source.parent).label
            errorMessageArray.push("* " + errField); 
        }
        Alert.show(errorMessageArray.join("\n"), "The following required fields must be completed before submission:", Alert.OK);
        coversheetShow = false;
		return;
	}
}
 
 
<mx:FormItem required="true" verticalGap="0" enabled="{editMode}">
	<mx:RadioButtonGroup id="attended" selectedValue="{report.attended}"/>
	<mx:RadioButton groupName="attended" label="Yes" value="1" />
	<mx:RadioButton groupName="attended" label="No" value="0" />
</mx:FormItem>
 
<mx:StringValidator source="{attended}" property="selectedValue" required="true"/>

Open in new window

0
 
Fuzzy_Logic_Commented:
the error is thrown, I believe, because report.attended is null.

If you were to enter a number instead, the code would work.

You need to make sure report.attended has a value.
0
 
hallikpapaAuthor Commented:
the default value for report (ReportVO) is -1

I will do some further investigation, but you are probably right.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Become an IT Security Management Expert

In today’s fast-paced, digitally transformed world of business, the need to protect network data and ensure cloud privacy has never been greater. With a B.S. in Network Operations and Security, you can get the credentials it takes to become an IT security management expert.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now