flex: working with checkboxes

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?

thanks
royjaydAsked:
Who is Participating?
 
Pravin AsarConnect With a Mentor Principal Systems EngineerCommented:
Flex RemoteObject method can help you with that.

http://whatwouldnickdo.com/wordpress/532/calling-multiple-methods-from-one-remoteobject-in-flex-and-actionscript-using-blazeds/


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

http://www.brightworks.com/flex_ability/?p=73

Look at

http://livedocs.adobe.com/blazeds/1/blazeds_devguide/help.html?content=lcoverview_4.html


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="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
      <mx:Script>
            <![CDATA[
                  import mx.events.CollectionEvent;
                  [Bindable] public var selected:String="";
                  public function update():void {
                        selected="";
                        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:Script>
      <mx:ArrayCollection id="srcData">
            <mx:source>
                  <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:source>            
      </mx:ArrayCollection>
      <mx:HBox>
            
      <mx:DataGrid dataProvider="{srcData}" width="200" height="400">
            <mx:columns>
                  <mx:DataGridColumn headerText="Selected Options" dataField="selected">
                        <mx:itemRenderer>
                              <mx:Component>
                                    <mx:CheckBox label="{data.display}" selected="{data.selected}" click="data.selected= !data.selected; outerDocument.srcData.refresh(); outerDocument.update(); trace(data.selected);"/>
                              </mx:Component>
                        </mx:itemRenderer>
                  </mx:DataGridColumn>
            </mx:columns>
      </mx:DataGrid>
      <mx:DataGrid dataProvider="{srcData}" width="200" height="400"/>
      <mx:TextInput text="{selected}"/>
      </mx:HBox>
                  
</mx:Application>

0
 
Pravin AsarPrincipal Systems EngineerCommented:
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

http://www.devrecipes.com/2009/04/20/flex-with-java-servlets-how-to-use-xml-from-an-httpservice-to-populate-a-data-gridtable/

0
 
royjaydAuthor Commented:
>>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.

thanks
0
 
royjaydAuthor Commented:
any help anyone?

thanks in advance.
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.

All Courses

From novice to tech pro — start learning today.