tags:

views:

23

answers:

1

Hi guys.. I am trying to load bunch of product detail into a canvas component from a List component.

Every time the user clicks on a product inside my List, the product detail will be displayed in the canvas component. The product detail might contain null and I want to check it before displaying in my canvas component.

In my canvas component, I use createcomplete to check if the productDetail==null then do something. My problem is if the user clicks the product with the non-null detail first time, the statement "if (productDetail==null) then do something" won't work if the user click a null product detail because the canvas component has been created the first time user clicks a non-null product detail.

I want to check if the productDetail==null every time the user click a product...I hope I explain my question well and appreciate any helps.

My code..

AS:

protected function changeHandler(event:IndexChangeEvent):void{

   compDetailinfoResult.token=getCompList.compDetail(event.target.selectedItem.productId);//get the product detail clicked by the user

}


<s:List dataProvider={productData}/>  //when user click a product, 
                                      //the canvas will show product detail..

<comp:productDetail productData={compDetailinfoResult.lastResult} //custom property 
                    change="changeHandler"/>  //if the product detail is 
                 //null, the statement inside 
                 //the canvas will check via 
                 //creationComplete. but if the 
                 //user click the non-null product, 
                 //the creationComplete check pass. User clicks a null product again,  
                 //the check won't work anymore...

code for my productDetail component:

public var productData:arrayCollection

protected function canvas1_creationCompleteHandler(event:FlexEvent):void
{
var undefinedBrand:String=dataFromClick.getItemAt(0).brand;

    if(undefinedBrand==null){   // I want to check every time the user click a List item
      brand.text="Brand: No Brand";
      switchView.enabled=false;
      displayPictureBig.source="assets/vacant.jpg";
     }
}

    <s:Panel>
       <label id="brand" text="productDate.getItemAt(0).brand"/> 
//I want the brand to be displayed..
//but if brand is null..it will display No Brand..
//see AC above...but createComplete only fire once.
//Anyway to keep tracking if the brand that is sent by List is null?
    </s:Panel

Thanks for the helps..

+1  A: 

I'm having some trouble understanding your issue. Are you referring explicitly to Canvas, the Halo container? Or did you name one of your custom components Canvas? If it is custom, as your code suggests, what is inside the component?

creationComplete is an event that only fires once, when the component finishes running the component lifecycle creation process for the first time. Your code snippets do not show any data being passed from the list into the canvas, so that could be one reason why the data is null.

If someone selects a new item on the list, the change event should dispatch. You can add an event listener to the change event and use it to update the data you are sending into your canvas component.

www.Flextras.com
Sorry for the confusion. I only paste very basic code here. Please see updated code...
Jerry
I do have the data that is sent by the main application. The productDetail component receive the data and display it. The product detail will change depend on which product the user click in the List. Some product brand is null and I want to display No Brand when the user click the no brand product...Thanks for the help...:D
Jerry