Announcement Announcement Module
Collapse
No announcement yet.
Cairngorm MVC Example Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cairngorm MVC Example

    Hi,

    I am interested in using Spring Actionscript and Cairngorm MVC, thus I have followed Documentation 3.1.1. Cairngorm.
    But it does not work.

    The following configuration is what I followed the above chapter:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <objects xmlns="http://www.springactionscript.org/schema/objects" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
    	xsi:schemaLocation="http://www.springactionscript.org/schema/objects http://www.springactionscript.org/schema/objects/spring-actionscript-objects-1.0.xsd">
    
    
    	<object id="appAwareCmdFactory" class="mykidong.command.ApplicationModelAwareCommandFactory">
    		<property name="applicationModel" ref="applicationModel"/>
    		<method-invocation name="addBusinessDelegateFactory">
    			<arg>
    				<ref>businessDelegateFactory</ref>
    			</arg>
    			<arg>
    				<array>
    					<value type="Class">mykidong.command.GetProductItemsCommand</value>
    				</array>
    			</arg>
    		</method-invocation>
    	</object>
    
    
    	<object id="applicationModel" class="mykidong.model.ApplicationModel" singleton="true"/>
    	
    									
    	<object id="moduleOneFrontController"
    		class="org.springextensions.actionscript.cairngorm.control.CairngormFrontController">
    		<constructor-arg>
    			<object>				
    				<property name="getProductItems" value="GetProductItemsCommand"/>
    			</object>
    		</constructor-arg>		
    		<constructor-arg value="mykidong.command"/>
    		<method-invocation name="addCommandFactory">
    			<arg><ref>appAwareCmdFactory</ref></arg>
    		</method-invocation>
    	</object>		
    
        <!--
    	<object id="frontcontrollerWireAgent" class="mykidong.controller.CairngormFrontControllerWireAgent">
    		<constructor-arg>
    			<dictionary>
    				<entry key="myModule" value="moduleOneFrontController"/>
    			</dictionary>
    		</constructor-arg>
    	</object>	
    
    	<si:stageinterceptor target-object="frontcontrollerWireAgent" target-method="evaluate"
    						object-selector="moduleSelector" id="stageInterceptor"/>
    
    	<object id="moduleSelector"
    			class="org.springextensions.actionscript.ioc.wire.TypeBasedObjectSelector">
    		<constructor-arg>
    			<array>
    				<value type="class">mx.modules.Module</value>
    			</array>
    		</constructor-arg>
    	</object>
    	-->
    	
    	<object id="businessDelegateFactory"
    		class="org.springextensions.actionscript.cairngorm.business.BusinessDelegateFactory">
    		<property name="service" ref="testService"/>
    		<property name="delegateClass" type="class" value="mykidong.service.GetProductItemsDelegate"></property>
    	</object>
    
    	
    	<object id="serviceLocator"
    		class="org.springextensions.actionscript.cairngorm.business.CairngormServiceLocator"
    		factory-method="getInstance">
    		<property name="testService">
    			<ref>testService</ref>
    		</property>
    	</object>
    	
    	<object id="testService" template="remoteObject">
    		<param name="serviceClass" value="someservice"/>
    	</object>
    	
    	<template id="remoteObject">
    		<object class="mx.rpc.remoting.mxml.RemoteObject">
    			<property name="destination" value="ColdFusion"/>
    			<property name="source" value="com.myremoteobjects.${serviceClass}"/>
    			<property name="channelSet">
    				<ref>channelset</ref>
    			</property>
    		</object>
    	</template>
    	
    	<object id="amfChannel" class="mx.messaging.channels.AMFChannel">
    		<constructor-arg value="my-amf"/>
    		<constructor-arg value="http://{server.name}:{server.port}/flex2gateway/" />
    		<property name="id" value="amfChannel"/>
    		<property name="pollingEnabled" value="false"/>
    	</object>
    	
    	<object id="channelset" class="mx.messaging.ChannelSet">
    		<method-invocation name="addChannel">
    			<arg>
    				<ref>amfChannel</ref>
    			</arg>
    		</method-invocation>
    	</object>		
    	
    </objects>

    And in my main mxml, application context is loaded and dispatch an event to show some product items like this:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    				xmlns:control="mykidong.controller.*"			
    				xmlns:view="mykidong.view.*"			
    				creationComplete="onCreationComplete();"
    				pageTitle="CairngormPlayList"
    				width="100%"
    				height="100%"
    				styleName="main"
    				horizontalAlign="center">
    
    	<mx:Script>
    		<![CDATA[		
    			import mx.rpc.remoting.mxml.RemoteObject;
    			
    			import org.springextensions.actionscript.context.support.FlexXMLApplicationContext;
    			import org.springextensions.actionscript.cairngorm.business.CairngormServiceLocator;
    			import org.springextensions.actionscript.context.support.XMLApplicationContext;
    			import org.springextensions.actionscript.cairngorm.control.CairngormFrontController;
    			import org.springextensions.actionscript.cairngorm.business.BusinessDelegateFactory;
    
    			import com.adobe.cairngorm.control.CairngormEventDispatcher;
    			import com.adobe.cairngorm.control.CairngormEvent;
    			
    			import mykidong.model.IApplicationModel;	
    			import mykidong.command.GetProductItemsCommand;
    			import mykidong.command.ApplicationModelAwareCommandFactory;
    			import mykidong.service.GetProductItemsDelegate;
    			import mykidong.event.GetProductItemsEvent;
    			
    			
    			private var _applicationModelAwareCommandFactory:ApplicationModelAwareCommandFactory;
    			private var _businessDelegateFactory:BusinessDelegateFactory;
    			private var _getProductItemsDelegate:GetProductItemsDelegate;
    			private var _cairngormFrontController:CairngormFrontController;			
    			private var _cairngormServiceLocator:CairngormServiceLocator;
    			private var _remoteObject:RemoteObject;
    			
    			[Bindable]
    			private var _model:IApplicationModel;
    			
    			private var _commands:Array = [GetProductItemsCommand];			
    
    			private var _applicationContext:FlexXMLApplicationContext;
    
    			private function onCreationComplete():void {
    				_applicationContext = new FlexXMLApplicationContext("application-context.xml");
    				_applicationContext.addEventListener(Event.COMPLETE, onApplicationContextComplete);
    				_applicationContext.load();				
    					
    				_model = _applicationContext.getObject("applicationModel") as IApplicationModel;				
    			}
    
    			private function onApplicationContextComplete(event:Event):void {
    				var getProductItemsEvent:GetProductItemsEvent = new GetProductItemsEvent();		
    				getProductItemsEvent.dispatch();								
    			}
    		
    		]]>
    	</mx:Script>
    
    	<!-- ========================================================================== -->
    
    	<mx:Label text="Cairngorm" />
    	
    	<mx:Panel x="10" y="10" width="650" height="230" layout="vertical">   	    
    		<mx:DataGrid dataProvider="{_model.productItems}" width="100%" height="100%"/>			
    	</mx:Panel>	
    </mx:Application>

    I have no idea where it went wrong.

    I have downloaded cairngorm sample from svn, CairngormStore, which works fine, but this sample codes have not been changed to What is mentioned in documentation 3.1.1.
    Could I get some example with using Spring ActionScript and Cairngorm like in doc 3.1.1. ?

    - Kidong Lee

  • #2
    please post some more code

    Hi Kidong,

    I suspect the id of your event doesn't match up with your controller configuration. Can you post the source code of the getProductItemsEvent?

    thanks in advance,

    cheers,

    Roland

    Comment


    • #3
      My Problem Solved.

      Hi Roland,

      thank you for your reply.

      I have struggled with my problem for some time, and I got success.
      In fact, I got some idea from the following link in the form:
      http://forum.springsource.org/showthread.php?t=74133

      , with the thread title 'Spring ActionScript + Cairngorm Example and Questions'.

      I have attached my sample zip 'cairngorm-springas-sample.zip', in which flex application with cairngorm + spring actionscript, and remoting data service application with spring blaze DS are involved.

      As I mentioned before, I could not get started easily to have cairngorm mvc + spring actionscript just with spring actionscript documentation. I think, it would be helpful that there is a good sample for that.

      - Kidong Lee

      Comment


      • #4
        Praise

        Dear Kidong,

        thank you for saving me (and probably others) a lot of frustration with that example!

        kudos,
        Nils

        Comment

        Working...
        X