Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Refresh a view every load

Posted on 2008-10-30
3
Medium Priority
?
1,375 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 600 total points
ID: 22883987
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
ID: 22886192
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
ID: 22889066
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

Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

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…
Often, the users face difficulty in accessing Outlook 2016 PST files on Windows 10 computer. One of the reasons behind it is the improper functioning of MS Outlook when the user tries to open it. MS Outlook suddenly stops working, or it will not op…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
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

571 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