Click here to Skip to main content
15,894,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i'm new to this flex please help, i'm facing some issue i'll post those codes.
Actually i trying to pass a list from java class to combo box in flex.

ActionScript:
*********************************

C#
package assets.actionScript
{
    import mx.collections.ArrayCollection;
    import mx.controls.List;

    [Bindable]
    [RemoteClass(alias="com.connectm.telecom.commandcenter.dto.CommandCenterConfigPaceDTO")]

    public class CommandCenterConfigPace
    {
        public var command_config_id:int;
        public var command_name:String;
        public var command:String;
        public var command_disc:String;
        public var flag:String;

    }
}


****************************************
Java Class
****************************************
public List<CommandCenterConfigPaceDTO> getCommandNames()
	{
		DAO dao = new Telecom_DAO();
		Session session = dao.getHibernateSession();
		List<CommandCenterConfigPaceDTO> commandCenterConfigList = new ArrayList<CommandCenterConfigPaceDTO>();
		try
		{
			List commandCenterList = session.createSQLQuery("select command_config_id,command_name,command,command_disc,flag from command_center_config_pace where flag = 1").list();
			for(Object object:commandCenterList)
			{
				Object data[] = (Object[]) object;
				CommandCenterConfigPaceDTO commandCenterConfigPaceDTO = new CommandCenterConfigPaceDTO();
				commandCenterConfigPaceDTO.setCommand_config_id((Integer) data[0]);
				commandCenterConfigPaceDTO.setCommand_name(data[1].toString());
				commandCenterConfigPaceDTO.setCommand(data[2].toString());
				commandCenterConfigPaceDTO.setCommand_disc(data[3].toString());
				commandCenterConfigPaceDTO.setFlag(data[4].toString());
				commandCenterConfigList.add(commandCenterConfigPaceDTO);
			}
			
		}catch (Exception e) {
			// TODO: handle exception
			logger.error("Exception in EscalationLiveService to calling getCommandNames..."
					+ e.getMessage());
		}
		
		finally
		{
			if (session != null && session.isOpen())
			{
				dao.closeHibernateSession();
			}
		}
		return commandCenterConfigList;
		
	}


************************************************************
flex file:
***********************************************************
XML
<?xml version="1.0" encoding="utf-8"?>
<mx:Application  xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    creationComplete="callRemoteObject()"
    xmlns:local="alarmSlide.*" horizontalAlign="center"
    verticalAlign="middle" borderColor="#222222"
    backgroundGradientAlphas="[1.0, 1.0]"
    backgroundGradientColors="[#011234, #000000]">

<mx:RemoteObject id="remoteObject" destination="liveStatus"
    result="resultHandler(event);"
    fault="faultHandler(event);"/>


<mx:Script>
    <![CDATA[
        import mx.controls.Spacer;
        import mx.containers.ControlBar;
        import mx.controls.RadioButton;
        import mx.controls.RadioButtonGroup;
        import mx.containers.VBox;
        import mx.events.CloseEvent;

        import mx.collections.HierarchicalData;
        import mx.collections.XMLListCollection;
        import mx.messaging.channels.AMFChannel;
        import mx.messaging.ChannelSet;
        import mx.controls.Alert;
        import mx.messaging.messages.RemotingMessage;
        import mx.rpc.events.FaultEvent;
        import mx.rpc.events.ResultEvent;
        import assets.actionScript.TowerStatus;

        import mx.collections.ArrayCollection;
        import mx.managers.PopUpManager;

        [Embed(source='assets/warring.gif')]
        private var confirmIcon:Class;

        [Bindable] private var charCount:int =0;
        [Bindable] public var folderList:XMLList;
        [Bindable] public var folderCollection:XMLListCollection;
        // BlazeDS variables
        [Bindable] public var channelUrl:String;
        [Bindable] private var commandNamesList:ArrayCollection = new ArrayCollection();

        // to store tower configuration
         public static var data:ArrayCollection = new ArrayCollection();

         public var userID:int = 0;
         public var locID:int = 0;
         public var towerId:int = 0;
         public var isTowerLevel:Boolean = false;
         public var ipAddress:String ;
         public var isTowerLevelBeforeLevel:Boolean = false;
         public var dotaMessage:String="";
        //***************************************************************************************************************************************//
            /**
            * This method will be called as soon as SWF loads in the browser , creating a AMF channel which communicates to Java
            **/
            private function callRemoteObject():void{
                 cursorManager.setBusyCursor();


                userID = Application.application.parameters.userId;
                locID = Application.application.parameters.locID;
                ipAddress = Application.application.parameters.IP;
                towerId = Number(Application.application.parameters.towerId);

                var isTowerLevelStr:String = Application.application.parameters.isTowerLevel.toString();
                var isTowerLevelBeforeLevelStr:String = Application.application.parameters.isTowerLevelBeforeLevel.toString();
                isTowerLevel = (isTowerLevelStr == "true") ? true : false;
                isTowerLevelBeforeLevel = (isTowerLevelBeforeLevelStr == "true") ? true : false;
                channelUrl = "./messagebroker/amf";
                var cs:ChannelSet = new ChannelSet();
                var customChannel:AMFChannel = new AMFChannel("my-amf",channelUrl);
                cs.addChannel(customChannel);
                remoteObject.channelSet = cs;

                remoteObject.getDOTATowerXMLData(locID,isTowerLevel,towerId);
            }
//***************************************************************************************************************************************//

        /**
         * This mehtod helps into save all the configured towers
         **/
        private var towerIDColl:ArrayCollection;
        private var noofTower:Number=0;

        private function sendSMSToTower():void{
            noofTower = CommandCenterConfigPace.data.length;
            Alert.show("this." + noofTower);
            if(commandToBeSend.text==null || commandToBeSend.text !=""){
                if(noofTower > 0){
                    var alert:Alert = Alert.show("You have selected "+ noofTower+" Tower(s).\nYour message will send to each tower one by one.\nContinue?" ,
                     "Confirmation", Alert.YES|Alert.NO, this, confirmHandler, confirmIcon, Alert.NO);
                    alert.setStyle("backgroundColor", 0xffffff);
                    alert.setStyle("backgroundAlpha", 0.50);
                    alert.setStyle("borderColor", 0xffffff);
                    alert.setStyle("borderAlpha", 0.75);
                    alert.setStyle("color", 0x000000); // text color
                }else{
                    Alert.show("Please select the tower.");
                }
            }else{
                Alert.show("Message should not be empty.");
            }
        }

        private function confirmHandler(event:CloseEvent):void{
            if (event.detail == Alert.YES) {
                towerIDColl = new ArrayCollection();
                var towerStatus:TowerStatus = new TowerStatus();
                for(var i:uint=0; i<CommandCenterConfigPace.data.length; i++){
                    towerStatus = new TowerStatus();
                    towerStatus.towerId = int(CommandCenterConfigPace.data.getItemAt(i));
                    //Alert.show("tower is ::::::"+towerStatus.towerId);
                    towerIDColl.addItem(towerStatus);
                }
                //Alert.show(commandToBeSend.text+" message will send it to "+noofTower +" tower(s),it's doing backend.");
                remoteObject.sendDOTAMessageToTower(towerIDColl,commandToBeSend.text,userID,ipAddress);
            }else if(event.detail == Alert.NO ){

            }
        }

         private function callCount():void{
            charCount =commandToBeSend.text.length
            charCount++;
        }

        private function resultHandler(event:ResultEvent):void{
            var message:RemotingMessage = event.token.message as RemotingMessage;
            switch(message.operation)
            {
                case "getDOTATowerXMLData":
                    var xmlStr:String = event.result as String;
                    folderList = new XMLList(xmlStr);
                    folderCollection = new XMLListCollection(folderList);
                    //checkADG.dataProvider = new HierarchicalData(folderCollection);
                    checkADG.dataProvider = new HierarchicalData(folderCollection);
                    if(isTowerLevelBeforeLevel){
                        checkADG.validateNow();
                    }
                    checkADG.expandAll();
                    break;

                case "getCommandNames":
                    commandNamesList = new ArrayCollection();
                    commandNamesList = event.result as ArrayCollection
                    break;

                case "sendDOTAMessageToTower":
                     //    Alert.show("Send");
                      break;
                default:
                        Alert.show("Not able to read operation from Java program : " + message.operation);
                        break;
            }
            cursorManager.removeBusyCursor();
        }

        private function faultHandler(event:FaultEvent):void{
            var message:RemotingMessage = event.token.message as RemotingMessage;
            Alert.show("Please check your internet connectivity.");
        }

    ]]>

</mx:Script>

<mx:Style source="/assets/style/Tabular.css"/>

<mx:Panel width="100%" height="100%" title="Send SMS To Tower" color="#FFFFFF" id="mainPanel" layout="absolute">
    <mx:VBox width="100%" height="100%" backgroundColor="#E1E8F7">
        <mx:HBox width="100%" height="25">
            <mx:Label text="    Command Name" fontWeight="bold" fontSize="10" width="150" color="#080707"/>
            <mx:ComboBox id="commandNamesId" cornerRadius="0" width="376" fontSize="10" selectedIndex="1" dataProvider="{commandNamesList}" color="#0B0A0A"/>
        </mx:HBox>

        <mx:HBox width="100%" height="75">
            <mx:Label text="    Discription " fontWeight="bold" fontSize="10" width="150" color="#080707"/>
            <mx:TextInput width="376" id="discrip" editable="false" height="73" color="#0B0A0A"/>
        </mx:HBox>

        <mx:HBox width="100%" height="25">
            <mx:Label text="    Command " fontWeight="bold" fontSize="10" width="150" color="#080707"/>
            <mx:TextInput id="commandToBeSend" width="377" height="25" color="#0B0A0A"/>
        </mx:HBox>

        <mx:HBox width="100%" height="25">
            <mx:Spacer width="300" height="10"/>
            <mx:Button x="500" toolTip="Send Message" label="Submit" height="25" width="75" click="sendSMSToTower()" color="#080707"/>
        </mx:HBox>

        <mx:HBox width="100%" height="100%">
            <mx:AdvancedDataGrid id="checkADG" groupItemRenderer="assets.actionScript.DotaADGRenderer"
                                 width="100%" height="100%" color="#000000"
                                 horizontalScrollPolicy="on"
                                 resizableColumns="true" x="0" y="26">
                <mx:columns>
                    <mx:AdvancedDataGridColumn headerText="Tower Hierarchy" dataField="@label" showDataTips="true" width="500"/>
                    <mx:AdvancedDataGridColumn headerText="SIM Number" dataField="@simNumber" showDataTips="true"  width="300"/>
                </mx:columns>
            </mx:AdvancedDataGrid>
        </mx:HBox>
    </mx:VBox>
</mx:Panel>

</mx:Application>



*************************************************************************
Please help me where i'm wrong. and changes should i do... please please help...
Posted
Comments
Nelek 14-Apr-12 9:52am    
You say "you are facing some issues", but you don't give any information about them.
Please use "improve question" and add a bit more info. I.e: What kind of errors? where are the being triggered?
april88t 2-Mar-13 2:19am    
yes Nelek is right! please be more specific..
lindam88 8-Mar-13 22:07pm    
you just paste your codes without clarifying what part of that is your problem..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900