Created
July 17, 2010 04:08
-
-
Save squeedee/479231 to your computer and use it in GitHub Desktop.
Mediating ItemRenderers http://devblog.vworkapp.com/post/822228597/mediating-itemrenderers-again
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<s:ItemRenderer | |
xmlns:fx="http://ns.adobe.com/mxml/2009" | |
xmlns:s="library://ns.adobe.com/flex/spark" | |
xmlns:vo="com.visfleet.radiator.vo.*" | |
> | |
<fx:Declarations> | |
<vo:JobVO id="jobVO" /> | |
</fx:Declarations> | |
<s:HGroup> | |
<s:Label text="{jobVO.name}" color="0xffffff"/> | |
</s:HGroup> | |
</s:ItemRenderer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.visfleet.radiator.view.perspectiveOverview.card { | |
import com.visfleet.core.isNull; | |
import com.visfleet.radiator.model.JobListModel; | |
import com.visfleet.radiator.vo.JobVO; | |
import mx.events.FlexEvent; | |
import org.robotlegs.mvcs.Mediator; | |
public class JobCardMediator extends Mediator { | |
[Inject] | |
public var view:JobCard; | |
[Inject] | |
public var model:JobListModel; | |
override public function onRegister():void { | |
addViewListener(FlexEvent.DATA_CHANGE,handleDataChange,FlexEvent); | |
updateFromModel(); | |
} | |
private function handleDataChange(event:FlexEvent):void { | |
updateFromModel(); | |
} | |
// Not as crazy as it looks, read the article. | |
private function updateFromModel():void { | |
if (isNull(view) || isNull(view.data)) | |
return; | |
var viewJobVO:JobVO = JobVO(view.data); | |
view.jobVO = model.getJobByName(viewJobVO.name); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<s:ItemRenderer | |
xmlns:fx="http://ns.adobe.com/mxml/2009" | |
xmlns:s="library://ns.adobe.com/flex/spark" | |
> | |
<s:HGroup> | |
<s:Label text="{data.name}" color="0xffffff" /> | |
</s:HGroup> | |
</s:ItemRenderer> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment