flex: working with checkboxes

Posted on 2011-05-11
Last Modified: 2012-05-11
hi guys

what is the best way to work with check boxes on the flex UI? I am using java in the backend
my requirment is i need some nice checkboxes on the UI which should be passed to the java backend.

any ideas?

Question by:royjayd
    LVL 28

    Expert Comment

    by:Pravin Asar
    To connect to back, you have few options such as RemoteObject, httpservice request.

    Can you be specific what you have or planning to use on server side.

    Here is good starter


    Author Comment

    >>Can you be specific what you have or planning to use on server side.

    I am using flex on the UI and using java with spring blazeds on the back.
    I have multiple check box fields like

    Country(check applicable values)
    Usa           --checkbox1
    Denmark   --checkbox2
    London     --checkbox3

    If usa and london is checked and denmark in unchecked , i need to pass all the checked and unchecked values to my java program in backend.
    I want to pass them in a arraycollection (in flex) which needs to get translated to ArrayList on the java side.
    any help would be helpful.


    Author Comment

    any help anyone?

    thanks in advance.
    LVL 28

    Accepted Solution

    Flex RemoteObject method can help you with that.

    It is bit more involved in terms of code and set-up at server side.

    Look at

    IF you are looking to cycle through data and pickup the values assoicated with selected checkboxes look at the following example code.

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="" layout="absolute" xmlns:local="*">
                      [Bindable] public var selected:String="";
                      public function update():void {
                            for (var ix:int=0; ix < srcData.source.length; ix++) {
                                  if (srcData.getItemAt(ix).selected) {
                                  trace (srcData.getItemAt(ix).value.toString());
                                  selected += srcData.getItemAt(ix).value.toString() + ',';
          <mx:ArrayCollection id="srcData">
                      <mx:Object display="Option 1" value="value1" selected="false"/>
                      <mx:Object display="Option 2" value="value2" selected="true"/>
                      <mx:Object display="Option 3" value="value3" selected="false"/>
                      <mx:Object display="Option 4" value="value4" selected="false"/>
          <mx:DataGrid dataProvider="{srcData}" width="200" height="400">
                      <mx:DataGridColumn headerText="Selected Options" dataField="selected">
                                        <mx:CheckBox label="{data.display}" selected="{data.selected}" click="data.selected= !data.selected; outerDocument.srcData.refresh(); outerDocument.update(); trace(data.selected);"/>
          <mx:DataGrid dataProvider="{srcData}" width="200" height="400"/>
          <mx:TextInput text="{selected}"/>


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now