Solved

Refresh a view every load

Posted on 2008-10-30
3
1,362 Views
Last Modified: 2012-05-05
Hi Guys

 I have a custom component an extended label and need a way of refreshing the view it is contained in everytime it is called.

The problem is only the URL will change which is done from within the component so I have no way to know when to invalidate the prop.

I have included the call and two files,

<common:customLabel screenID="overviewLinks" identify="accountType_title" linkName="Account Type" styleName="txtLabel" width="100" height="20" />


thanks,

John





<?xml version="1.0" encoding="utf-8"?>

<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" horizontalScrollPolicy="off" activate="invalidateProperties()">

	<mx:Script>

	 <![CDATA[

	 	import mx.collections.ArrayCollection;

		import mx.controls.Image;			

		import mx.managers.CursorManager;

		import flash.events.*;

		import com.sunlife.us.workbench.util.common.linkUrlFunction;

		
 

		[Bindable]	

			public var returnedArray : ArrayCollection = new ArrayCollection();

		[Bindable]	

			public var _linkURL:String = new String();

		[Bindable]	

			public var linkImage:String = new String();

		[Bindable]	

			public var	visibleImage:Boolean = false;

		[Bindable]	

			public var	screenID : String  = new String();

		[Bindable]

			public var identify : String  = new String();

		[Bindable]

			public var _linkName : String = new String();

	

			

		override protected function commitProperties():void

		

			{

				identify = this.identify;

				screenID = this.screenID;				

				returnedArray = linkUrlFunction.returnLink(identify,screenID);

				linkURL = String(returnedArray.getItemAt(0));

				linkImage = String(returnedArray.getItemAt(1));

				visibleImage = returnedArray.getItemAt(2);
 

				if(visibleImage){

					this.visibleImage = true;

				}

			}

			
 

			[Bindable(event="linkNameChanged")]

			public function get linkName():String {

			  return _linkName;

			}

			

			public function set linkName(value:String):void {

			  _linkName = value;

			

			  // calling this method will cause commitProperties() to be called in the next update

			  invalidateProperties();

			

			  // note that the event you dispatch has the same name as the one given in the Bindable metatag

			  dispatchEvent(new Event("linkNameChanged"));
 

			}

			

			

			

			// check the url also as the url may only change on some products

		

			[Bindable(event="linkURLChanged")]

			public function get linkURL():String {

			  return _linkURL;

			}

			

			public function set linkURL(value:String):void {

			  _linkURL = value;

			

			  // calling this method will cause commitProperties() to be called in the next update

			  invalidateProperties();

			

			  // note that the event you dispatch has the same name as the one given in the Bindable metatag

			  dispatchEvent(new Event("linkURLChanged"));
 

			}
 
 
 

	         public function linkHandler():void 

	         {

	         	identify = this.identify;

				screenID = this.screenID;				

				returnedArray = linkUrlFunction.returnLink(identify,screenID);

				

				var link2Use :String = new String();

				link2Use = String(returnedArray.getItemAt(0));

	         	

		        // Open the link in a new window, 

		        navigateToURL(new URLRequest(link2Use), '_link')

		     }

	       ]]>

	</mx:Script>

		

	<mx:HBox horizontalGap="-2" horizontalScrollPolicy="off" width="100%">

		<mx:Text text="{_linkName}" paddingRight="0" paddingLeft="0" id="textDisplay"/>

		<mx:Image enabled="{this.visibleImage}" visible="{this.visibleImage}" horizontalAlign="center" verticalAlign="middle"  source="{this.linkImage}" click="linkHandler()" buttonMode="true" scaleContent="true" width="17" height="17"/>

		

	</mx:HBox>
 

</mx:Canvas>
 
 
 
 
 
 
 
 
 
 
 
 
 

package custom

{

	import mx.collections.ArrayCollection;

	import com.sunlife.us.workbench.model.annuity.ModelLocatorAnnuity;

	import mx.utils.StringUtil;

	

	

	

	public class linkUrlFunction

	{

		

		public static function returnLink(linkID : String, screenID : String):ArrayCollection

		{

			screenID= StringUtil.trim(screenID);

			var modelAnnuity : ModelLocatorAnnuity = ModelLocatorAnnuity.getInstance();

			

			 var returnArray : ArrayCollection = new ArrayCollection();

			 var returnUrl : String = new String;

			 var returnImage : String = new String;;

			 var imagePath :String = "assets/images/";

			 var linkImage:String = new String;;

			 var identifyierArray : Object = new Object;

			 var visible : Boolean = new Boolean;

			 

			identifyierArray = new ArrayCollection;

			visible = false;

		

		

 		if( modelAnnuity.annuityOverviewVO.annuityWB2Links != null){

			switch(screenID)

			{

			case "bonusValuesLinks":

				identifyierArray = modelAnnuity.annuityOverviewVO.annuityWB2Links.bonusValuesLinks;		

				break;

			

			case "claimsLinks":

				identifyierArray = modelAnnuity.annuityOverviewVO.annuityWB2Links.claimsLinks;

				break;

				

			case "deathBenefitsLinks":

				identifyierArray = modelAnnuity.annuityOverviewVO.annuityWB2Links.deathBenefitsLinks;

				break;

		

			case "investmentsLinks":

				identifyierArray = modelAnnuity.annuityOverviewVO.annuityWB2Links.investmentsLinks;

				break;

		

			case "livingBenefitsLinks":

				identifyierArray = modelAnnuity.annuityOverviewVO.annuityWB2Links.livingBenefitsLinks;

				break;

			

			case "overviewLinks":

				identifyierArray = modelAnnuity.annuityOverviewVO.annuityWB2Links.overviewLinks;

				break;

			

			case "rmdLinks":

				identifyierArray = modelAnnuity.annuityOverviewVO.annuityWB2Links.rmdLinks;

				break;

			

			case "specialFeaturesLinks":

				identifyierArray = modelAnnuity.annuityOverviewVO.annuityWB2Links.specialFeaturesLinks;

				break;

			

			case "taxLinks":

				identifyierArray = modelAnnuity.annuityOverviewVO.annuityWB2Links.taxLinks;

				break;

			

			case "transactionsLinks": 

				identifyierArray = modelAnnuity.annuityOverviewVO.annuityWB2Links.transactionsLinks;

				break;

				

			default:

				

				returnArray.addItemAt("" , 0);

				returnArray.addItemAt("" , 1);

				returnArray.addItemAt("",2);

			}

		}

			else{

				

			returnArray.addItemAt("" , 0);

			returnArray.addItemAt("" , 1);

			returnArray.addItemAt("",2);

			trace("******************************************** ");

		

		}

		if (identifyierArray == null){

			

			returnArray.addItemAt("" , 0);

			returnArray.addItemAt("" , 1);

			returnArray.addItemAt("",2);

			trace("null object encountered ie. no array returned for current set for " + screenID);

		}

		

		else {

			

			if( identifyierArray.length > 0)

			{

				

				 for(var h : Number = 0; h < identifyierArray.length; h++)

				 {

					 if(StringUtil.trim(identifyierArray[h].flexId) == StringUtil.trim(linkID))

					 {

					 	returnUrl = String(identifyierArray[h].url)	

					 	linkImage = String(identifyierArray[h].iconType);

					 	h = identifyierArray.length; 		 	

					 }

				 }

				 

				 if((linkImage == null) || (linkImage.length < 1) || (returnUrl == "") ){			 	

					 visible = false;

					}

				else{

					

					returnImage = String(imagePath + StringUtil.trim(linkImage) +".gif")

					trace(returnImage);

					visible = true;	

					}

					

				returnArray.addItemAt(returnUrl , 0);

				returnArray.addItemAt(returnImage , 1);

				returnArray.addItemAt(visible,2);

		

			}

			

		}

	

		return(returnArray);

		}

	}
 

}

Open in new window

0
Comment
Question by:jdunneuk
  • 2
3 Comments
 
LVL 19

Assisted Solution

by:Gary Benade
Gary Benade earned 150 total points
Comment Utility
That component is dispatching events when things change, you should be able to listen for the urlchanged event in your container and respond to that


<common:customLabel id="surl" screenID="overviewLinks" identify="accountType_title" linkName="Account Type" styleName="txtLabel" width="100" height="20" />

// add to your view creationComplete event
surl.addEventListener( "linkURLChanged", doUpdate);
0
 
LVL 3

Accepted Solution

by:
jdunneuk earned 0 total points
Comment Utility
I figured it out, watching the url was not enough i put the URL in an array collection and it worked as I watched everything from there
0
 
LVL 19

Expert Comment

by:Gary Benade
Comment Utility
Congrats, very glad to hear you found a solution, good job!. Out of professional interest I'd like to see what it was if you don't mind, never too old to learn, thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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…
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

11 Experts available now in Live!

Get 1:1 Help Now