Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Not able to pass ValueObject to component

Posted on 2011-02-18
2
Medium Priority
?
458 Views
Last Modified: 2012-05-11
Hi Expert,

I am trying to pass one ValueObject from my main application to one of the component which is used in the main application.
It is showing null.
could you please tell where i am wrong.
Here is my code attached.
In Main Application:
--------------------
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
				   xmlns:s="library://ns.adobe.com/flex/spark"
				   xmlns:mx="library://ns.adobe.com/flex/mx"
				   xmlns:comp="com.att.ntscp.view.component.*" 
				   skinClass="com.att.ntscp.view.style.CommandApplicationContainerSkin"
				   width="100%" height="700" creationComplete="init();">
<fx:Script>
    <![CDATA[
    public var commandName:String;
    public var cardType:String;
    public var commandType:String;
    public var attuid:String;
    public var cmd:CommandVO;

    public function init():void{
				commandId = FlexGlobals.topLevelApplication.parameters['commandId'];
				commandName = FlexGlobals.topLevelApplication.parameters['commandName'];
				cardType = FlexGlobals.topLevelApplication.parameters['cardType'];
				commandType = FlexGlobals.topLevelApplication.parameters['commandType'];
				cmd = new CommandVO();
				cmd.commandId = commandId;
				cmd.commandName = commandName;
				cmd.cardType = cardType;
				cmd.cmdType = commandType;
				comp.fetchCmdDtls();
				
			}
		]]>
</fx:Script>

	<mx:VBox id="cmdbox5" resizeEffect="{resize}" width="100%" height="700" backgroundColor="0xEEF9F8" horizontalScrollPolicy="off" >
		<comp:SomeComponent id="comp"/>
	</mx:VBox>
</s:Application>

SomeComponent.mxml
-------------------
<s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:comp="com.att.ntscp.view.component.*" width="100%" 
>

<fx:Script>
    <![CDATA[
     import com.att.ntscp.vo.CommandVO;	
     import mx.core.FlexGlobals;		
     private var commandId:int;			
     private var commandName:String;
     private var commandType:String;
     private var cardType:String;
     private var attuid:String;	      	             public var cmdVO:CommandVO;

public function fetchCmdDtls():void{
Debug.echo(producer,this.toString(),"::SubComp In fetchDetls()","#0000FF")// after this statement, control is not going
commandId = int(cmdVO.commandId);
Debug.echo(producer,this.toString(),"::SubComp In fetchDetls() commandId = "+commandId,"#0000FF")
if(commandId<=0) {
commandId = -1;
}
commandName = cmdVO.commandName;
Debug.echo(producer,this.toString(),"::SubComp In fetchDetls() commandName = "+commandName,"#0000FF")
commandType = cmdVO.cmdType;
cardType = cmdVO.cardType;				
ntscpSrv.getCommandHelp(commandId,commandName,commandType,cardType);//calling remote method	
}

Here is the CommandVO.as
------------------------
[RemoteClass(alias="nscom.FrameWork.Command")]
	public class CommandVO
	{
		public function CommandVO()
		{
		}
		public var commandId:String;
		public var commandName:String;
		public var cardType:String;
		public var cmdType:String;
		public var commandDescription:String;
		public var argumentList:ArrayCollection;
		...

Open in new window

0
Comment
Question by:Alpita
2 Comments
 
LVL 17

Accepted Solution

by:
deepanjandas earned 2000 total points
ID: 34931239
Try this:
 
public function init():void{
                                commandId = FlexGlobals.topLevelApplication.parameters['commandId'];
                                commandName = FlexGlobals.topLevelApplication.parameters['commandName'];
                                cardType = FlexGlobals.topLevelApplication.parameters['cardType'];
                                commandType = FlexGlobals.topLevelApplication.parameters['commandType'];
                                cmd = new CommandVO();
                                cmd.commandId = commandId;
                                cmd.commandName = commandName;
                                cmd.cardType = cardType;
                                cmd.cmdType = commandType;
                                comp.cmdVO = cmd;
                                comp.fetchCmdDtls();
                                
                        }
                ]]>

Open in new window


Warm Regards
Deepanjan Das
0
 

Author Closing Comment

by:Alpita
ID: 34931507
Thanks. Now, it is fine.
0

Featured Post

Prepare for an Exciting Career in Cybersecurity

Help prevent cyber-threats and provide solutions to safeguard our global digital economy. Earn your MS in Cybersecurity. WGU’s MSCSIA degree program curriculum features two internationally recognized certifications from the EC-Council at no additional time or cost.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Your business may be under attack from a silent enemy that is hard to detect. It works stealthily in the shadows to access and exploit your critical business information, sensitive confidential data and intellectual property, for commercial gain. T…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

876 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