3 Replies Latest reply on Mar 19, 2007 5:57 PM by ntsiii

    ValueObjects / Referencing Custom Components

    blastbeat
      All,

      I have recently built a bug tracker in Flex and it works great. I am now attempting to break out the inline RPC calls into custom components and apply valueObject theory if suitable.

      Here's an example.

      I have a drop-down list that provides severity levels for the user to select. I get the severity levels from a CFC invoked by a RPC in my main.mxml file. Since the severity list will potentially need to be invoked in other areas (reports, etc) I've removed the Event Handler and RPC call from main.mxml and created a new file called SeverityList. If I am understanding Flex at all, this is now a custom component.

      So now I have this custom component I need to invoke in main.mxml and produce my SeverityList. My custom component is as follows:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:Script>
      <![CDATA[
      import mx.rpc.events.ResultEvent;
      import mx.collections.ArrayCollection;

      [Bindable] public var SeverityList:ArrayCollection;

      public function SeverityLevels(event:ResultEvent):void{
      SeverityList = event.result as ArrayCollection;
      }

      ]]>
      </mx:Script>

      <mx:RemoteObject id="rpcSeverityLevels" destination="Coldfusion" source="SeverityLevels">
      <mx:method name="getAll" result="SeverityLevels(event)" />
      </mx:RemoteObject>

      </mx:Application>

      Further, should I put the result of this RPC into a valueObject class? The chapter on these in the training book is great, but fails to explain how to chain the mxml, .as class file and custom component together, so I would need to understand how to do that as well. Perhaps a valueObject would be overkill for something like this and more suitable for keeping state of a shopping cart or what not?

      Would appreciate any opinions!