<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    云自無(wú)心水自閑

    天平山上白云泉,云自無(wú)心水自閑。何必奔沖山下去,更添波浪向人間!
    posts - 288, comments - 524, trackbacks - 0, articles - 6
      BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

    The major change to this release is how Cairngorm is being packaged. Cairngorm 2.1 introduced a dependency on fds.swc, which isn't part of the standard Flex SDK - it is part of FDS. So, we've repackaged Cairngorm into the core Cairngorm and Cairngorm Enterprise - this also starts aligning Cairngorm with Steven Webster's presentation at Max when he spoke about the Cairngorm Roadmap. We're also now going to to distribute Cairngorm in Binary form (SWC), as a source zip and a documentation zip.

    * Removed dependency on Flex Data Services (fds.swc) - externalised to Cairngorm Enterprise
    * Flex SDK SWCs are no longer linked into Cairngorm.swc (produces a smaller cairngorm.swc)
    * Added support for setting remote credentials
    * Fixed bug with Web services not loading the WSDL (no need to call loadWSDL() explicitly)
    * ModelLocator interface has been deprecated. Added com.adobe.cairngorm.model.IModelLocator
    * Added deprecation metadata for compiler support

    對(duì)于我來(lái)說(shuō),關(guān)注的只有一點(diǎn):ModelLocator被改成IModelLocator了。
    其他的只是Cairngorm的打包方式而已。
    Cairngorm2.1中依賴于fds.swc,而fds.swc不是Flex SDK中的東西,是FDS的一部分。
    在2.2中會(huì)將Cairngorm拆成兩部分:Core Cairngorm和Cairngorm Enterprise
    和FDS.swc相關(guān)的部分放入Cairngorm Enterprise中。

    posted @ 2007-01-25 21:08 云自無(wú)心水自閑 閱讀(1207) | 評(píng)論 (2)編輯 收藏

    首先在這個(gè)版本中,修正了數(shù)百個(gè)Bug

    1. 添加對(duì)Mac的支持
    2. 支持Eclipse 3.2,而不是僅僅支持3.1
    3. 運(yùn)行時(shí)的CSS支持
    4. 增加了一個(gè)Mercury的插件,支持自動(dòng)測(cè)試
    5. 其他一些很棒的功能:包括FlashType的字體和ASDoc的支持。

    posted @ 2007-01-21 13:54 云自無(wú)心水自閑 閱讀(518) | 評(píng)論 (0)編輯 收藏

    1. 要把database.properties和mail.properties拷貝到build/classes
    2. 要在數(shù)據(jù)庫(kù)中建立test用戶
    3. ant db-create建立數(shù)據(jù)庫(kù)
    4. ant db-prepare建立數(shù)據(jù)表
    5. ant db-load 將數(shù)據(jù)插入到數(shù)據(jù)表中
    6. 修改myapp\build\classes\META-INF目錄中的applicationContext-hibernate.xml
    添加
    ??? <bean id="propertyConfigurer"
    ??? ??? class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    ??? ??? <property name="location"><value>database.properties</value></property>
    ??? </bean>

    ??? <bean id="dataSource"
    ??? ??? class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    ??? ??? <property name="driverClassName">
    ??? ??? ??? <value>${hibernate.connection.driver_class}</value>
    ??? ??? </property>
    ??? ??? <property name="url">
    ??? ??? ??? <value>${hibernate.connection.url}</value>
    ??? ??? </property>
    ??? ??? <property name="username">
    ??? ??? ??? <value>${hibernate.connection.username}</value>
    ??? ??? </property>
    ??? ??? <property name="password">
    ??? ??? ??? <value>${hibernate.connection.password}</value>
    ??? ??? </property>
    ??? </bean>
    7. 修改myapp\build\class\META-INF目錄下的applicationContext-service.xml
    將其中的mail.host, mail.username, mail.password, mail.default.from
    三個(gè)變量修改成合適的值
    8. ant deploy
    9. 啟動(dòng)tomcat, http://localhost:8080/myapp
    10. 輸入mraible,密碼tomcat,進(jìn)入系統(tǒng)

    posted @ 2007-01-17 01:50 云自無(wú)心水自閑 閱讀(367) | 評(píng)論 (1)編輯 收藏

    這個(gè)函數(shù)只是一個(gè)示例函數(shù),演示如何遍歷一個(gè)Tree。
    此函數(shù)嚴(yán)格說(shuō)起來(lái)其實(shí)是兩個(gè)函數(shù):上半部分用于回溯父節(jié)點(diǎn),下半部分遞歸遍歷子節(jié)點(diǎn)

    /**
    ?* This method will traverse a Tree's model independent of it's
    ?* type.
    ?*
    ?* <p>Note :: This method may look long and arduous but, rest assured
    ?* it has all the checks to perform like a champ. Also, you 'could'
    ?* refactor part of this method but, for the sake of explanation, I
    ?* kept it all in one place.</p>
    ?*
    ?* <p>Remember, I had coupled the model to this method by tracing
    ?* @label, obviously you do not need to do this. The intention of
    ?* this example is to show you that the dataDescriptor seperates
    ?* the models type and is awesome. It enables you to create a tight
    ?* method like this without type checks on the model.</p>
    ?*
    ?* @param tree The Tree instance that will be examined by the method.
    ?* @param item An item found in the dataProvider of the Tree passed in.
    ?* @param startAtParent A boolean that determines if the method upon
    ?* initialization will back up one leve3l to the item passed in and
    ?* start it's recursion at the item's parent node.
    ?*/

    public function walkTree(tree:Tree, item:Object, startAtParent:Boolean = false):void
    {
    ? ? // get the Tree's data descriptor
    ? ? var descriptor:ITreeDataDescriptor = tree.dataDescriptor;
    ? ? var cursor:IViewCursor;
    ? ?
    ? ? var parentItem:Object;
    ? ? var childItem:Object;
    ? ? var childItems:Object;
    ? ?
    ? ? // if the item is null, stop
    ? ? if(item == null)
    ? ? ? ? return;
    ? ? ? ?
    ? ? // do we back up one level to the item's parent
    ? ? if(startAtParent)
    ? ? {
    ? ? ? ? // get the parent
    ? ? ? ? parentItem = tree.getParentItem(item);
    ? ? ? ? // is the parent real
    ? ? ? ? if(parentItem)
    ? ? ? ? {
    ? ? ? ? ? ? trace("|-- Parent Node ", parentItem[tree.labelField]);
    ? ? ? ? ? ? // if the parent is a branch
    ? ? ? ? ? ? if(descriptor.isBranch(parentItem))
    ? ? ? ? ? ? {
    ? ? ? ? ? ? ? ? // if the branch has children to run through
    ? ? ? ? ? ? ? ? if(descriptor.hasChildren(parentItem))
    ? ? ? ? ? ? ? ? {
    ? ? ? ? ? ? ? ? ? ? // get the children of the branch
    ? ? ? ? ? ? ? ? ? ? // this part of the algorithm contains the item
    ? ? ? ? ? ? ? ? ? ? // passed
    ? ? ? ? ? ? ? ? ? ? childItems = descriptor.getChildren(parentItem);
    ? ? ? ? ? ? ? ? }
    ? ? ? ? ? ? }
    ? ? ? ? ? ? // if the branch has valid child items
    ? ? ? ? ? ? if(childItems)
    ? ? ? ? ? ? {
    ? ? ? ? ? ? ? ? // create our back step cursor
    ? ? ? ? ? ? ? ? cursor = childItems.createCursor();
    ? ? ? ? ? ? ? ? // loop through the items parent's children (item)
    ? ? ? ? ? ? ? ? while(!cursor.afterLast)
    ? ? ? ? ? ? ? ? {
    ? ? ? ? ? ? ? ? ? ? // get the current child item
    ? ? ? ? ? ? ? ? ? ? childItem = cursor.current;

    ? ? ? ? ? ? ? ? ? ? var label:String = childItem[tree.labelField];
    ? ? ? ? ? ? ? ? ? ? var branch:Boolean = descriptor.isBranch(childItem);
    ? ? ? ? ? ? ? ? ? ?
    ? ? ? ? ? ? ? ? ? ? // good place for a custom method()
    ? ? ? ? ? ? ? ? ? ? trace("Sibling Nodes :: ", label, "Is Branch :: ", branch);
    ? ? ? ? ? ? ? ? ? ?
    ? ? ? ? ? ? ? ? ? ? // if the child item is a branch
    ? ? ? ? ? ? ? ? ? ? if(descriptor.isBranch(childItem))
    ? ? ? ? ? ? ? ? ? ? ? ? // traverse the childs branch all the way down
    ? ? ? ? ? ? ? ? ? ? ? ? // before returning
    ? ? ? ? ? ? ? ? ? ? ? ? walkTree(tree, childItem);
    ? ? ? ? ? ? ? ? ? ? // do it again!
    ? ? ? ? ? ? ? ? ? ? cursor.moveNext();
    ? ? ? ? ? ? ? ? }
    ? ? ? ? ? ? }
    ? ? ? ? }
    ? ? }
    ? ? else// we don't want the parent OR this is the second iteration
    ? ? {
    ? ? ? ? // if we are a branch
    ? ? ? ? if(descriptor.isBranch(item))
    ? ? ? ? {
    ? ? ? ? ? ? // if the branch has children to run through
    ? ? ? ? ? ? if(descriptor.hasChildren(item))
    ? ? ? ? ? ? {
    ? ? ? ? ? ? ? ? // get the children of the branch
    ? ? ? ? ? ? ? ? childItems = descriptor.getChildren(item);
    ? ? ? ? ? ? }
    ? ? ? ? ? ?
    ? ? ? ? ? ? // if the child items exist
    ? ? ? ? ? ? if(childItems)
    ? ? ? ? ? ? {
    ? ? ? ? ? ? ? ? // create our cursor pointer
    ? ? ? ? ? ? ? ? cursor = childItems.createCursor();
    ? ? ? ? ? ? ? ? // loop through all of the children
    ? ? ? ? ? ? ? ? // if one of these children are a branch we will recurse
    ? ? ? ? ? ? ? ? while(!cursor.afterLast)
    ? ? ? ? ? ? ? ? {
    ? ? ? ? ? ? ? ? ? ? // get the current child item
    ? ? ? ? ? ? ? ? ? ? childItem = cursor.current;

    ? ? ? ? ? ? ? ? ? ? var label:String =? childItem[tree.labelField];
    ? ? ? ? ? ? ? ? ? ? var branch:Boolean = descriptor.isBranch(childItem);
    ? ? ? ? ? ? ? ? ? ?
    ? ? ? ? ? ? ? ? ? ? // good place for a custom method()
    ? ? ? ? ? ? ? ? ? ? trace("-- Sub Node :: ", label, "Is Branch :: ", branch);

    ? ? ? ? ? ? ? ? ? ? // if the child item is a branch
    ? ? ? ? ? ? ? ? ? ? if(descriptor.isBranch(childItem))
    ? ? ? ? ? ? ? ? ? ? ? ? // traverse the childs branch all the way down
    ? ? ? ? ? ? ? ? ? ? ? ? // before returning
    ? ? ? ? ? ? ? ? ? ? ? ? walkTree(tree, childItem);
    ? ? ? ? ? ? ? ? ? ? // check the next child
    ? ? ? ? ? ? ? ? ? ? cursor.moveNext();
    ? ? ? ? ? ? ? ? }
    ? ? ? ? ? ? }
    ? ? ? ? }
    ? ? }
    }
    ?



    ?

    posted @ 2007-01-07 14:37 云自無(wú)心水自閑 閱讀(3496) | 評(píng)論 (1)編輯 收藏

    ?

    在Flex的開(kāi)發(fā)過(guò)程中,尤其是在使用Cairngorm的時(shí)候,總會(huì)遇到需要在Model的屬性值改變后,需要調(diào)用一個(gè)指定的函數(shù)。傳統(tǒng)的解決方法是使用一個(gè)Setter方法,在這個(gè)方法中首先對(duì)屬性賦值,然后調(diào)用指定的函數(shù),比如:

    ---------------------------
    [ChangeEvent("deleteEnabledChange")]
    public function get deleteEnabled() : Boolean {
    return _deleteButtonVisible;
    }

    public function set deleteEnabled(value : Boolean) : Void {
    _deleteButtonVisible = value;
    SimpleButton(deleteButton)._visible = false;
    dispatchEvent(new Event("deleteEnabledChange", this));
    }
    --------------

    但是現(xiàn)在我們有一個(gè)更簡(jiǎn)潔的解決之道
    首先添加這樣一個(gè)類(lèi)
    package com.adobe.ac.util
    {
    ?? public class Observe
    ?? {
    ????? public var handler : Function;
    ?
    ????? public function set source( source : * ) : void
    ????? {
    ???????? handler.call();
    ????? }
    ?? }
    }
    然后就可以使用這個(gè)作為標(biāo)簽了。
    <util:Observe source="{ model.myProperty }"
    ????????????? handler="{ this.myFunction }"/>
    使用了這樣的一個(gè)標(biāo)簽后,今后嘦是對(duì)model.myProperty進(jìn)行賦值,就會(huì)調(diào)用myFunction
    這個(gè)號(hào)稱(chēng)世上最小的標(biāo)簽是不是很好用啊?

    posted @ 2007-01-07 02:15 云自無(wú)心水自閑 閱讀(1097) | 評(píng)論 (4)編輯 收藏

    現(xiàn)在我們將增加驗(yàn)證、格式化和一些其他的功能。
    第四次迭代--添加功能
    現(xiàn)在我們回過(guò)頭來(lái)看那個(gè)單視圖的應(yīng)用,增加一點(diǎn)真實(shí)性,我們模擬一下遠(yuǎn)程服務(wù)有一點(diǎn)延時(shí)。我們?cè)贒elegate中使用flash.utils.setTimeOut來(lái)模擬延時(shí)。
    通常,當(dāng)遠(yuǎn)程服務(wù)在處理時(shí),UI會(huì)展現(xiàn)一個(gè)進(jìn)度條,禁用一部分控件,讓用戶明白不能再派發(fā)新的請(qǐng)求。在我們的例子中在遠(yuǎn)程服務(wù)在處理的時(shí)候,我們會(huì)禁用“Get Quote”按鈕。完成這一點(diǎn)很容易,只需要在Model對(duì)象的StockQuote類(lèi)中增加一個(gè)成員isPending,把它定義為一個(gè)bool形,這樣可以直接應(yīng)用于綁定。

    ?

    [Bindable]
    public ?var?isPending?:?Boolean;

    ?

    增加驗(yàn)證
    我們現(xiàn)在添加對(duì)股票報(bào)價(jià)的驗(yàn)證功能,對(duì)于這一點(diǎn),我們可以使用mx.validators.StringValidator來(lái)完成這一功能。應(yīng)用中這兩個(gè)參數(shù)共同控制按鈕的有效性。這樣可以在Model對(duì)象中設(shè)置一個(gè)isValid屬性,用于組合這兩參數(shù)。

    private ?function?validate()?:? void
    {
    ????isValid?
    = ?(?isSymbolValid? && ? ! isPending?);
    }

    isSymbolValid是一個(gè)屬性,存放StringValidator的結(jié)果。
    在StockMarketPod.mxml中添加mx:StringValidator這個(gè)Tag

    < mx:StringValidator?
    ????
    minLength ="2" ?triggerEvent ="change" ?
    ????source
    ="{?symbolTextInput?}" ?property ="text"
    ????valid
    ="stockQuote.validateSymbol(?true?);" ?
    ????invalid
    ="stockQuote.validateSymbol(?false?);" />


    從視圖中直接調(diào)用Model對(duì)象不符合MVC原則,因?yàn)橐晥D原則上只能派發(fā)事件。但在這個(gè)例子中,這樣已經(jīng)足夠好了。

    增加格式化
    我們將股票報(bào)價(jià)以金額的方式進(jìn)行展示,在StockMarketPod.mxml中增加一個(gè)formatter

    < mx:CurrencyFormatter?
    ????
    id ="standardEuroFormatter" ??
    ????currencySymbol
    ="$" ?precision ="2" />
    將formatter的結(jié)果進(jìn)行綁定
    < mx:Label? text ="{?standardEuroFormatter.format(?stockQuote.lastStockQuote?)?}" />


    現(xiàn)在看一下完整的StockQuote類(lèi)

    package ?com.adobe.cairngorm.samples.dashboard.model
    {
    ????
    public ? class ?StockQuote
    ????
    {
    ????????[Bindable]
    ????????
    public ?var?lastStockQuote?:?Number;
    ????????[Bindable]
    ????????
    public ?var?isValid?:?Boolean;
    ????????[Bindable]
    ????????
    public ?var?statusMessage?:?String;
    ????????????????
    ????????
    private ?var?_isPending?:?Boolean;
    ????????
    private ?var?isSymbolValid?:?Boolean;
    ????????????????
    ????????[Bindable]
    ????????
    public ?function?get?isPending()?:?Boolean
    ????????
    {
    ????????????
    return ?_isPending;
    ????????}

    ????????
    ????????
    public ?function?set?isPending(?value?:?Boolean?)?:? void
    ????????
    {
    ????????????_isPending?
    = ?value;
    ????????????validate();
    ????????}

    ????????????
    ????????
    public ?function?validateSymbol(?isValid?:?Boolean?)?:? void
    ????????
    {
    ????????????isSymbolValid?
    = ?isValid;
    ????????????validate();
    ????????}

    ????????
    ????????
    private ?function?validate()?:? void
    ????????
    {
    ????????????isValid?
    = ?(?isSymbolValid? && ? ! isPending?);
    ????????}
    ????????
    ????}

    }

    其中isPending屬性的值由GetStockQuoteCommand控制

    private ?var?model?:?ModelLocator? = ?ModelLocator.getInstance();
    private ?var?stockQuote?:?StockQuote? = ?model.stockQuote;
    ?????????
    public ?function?execute(?event?:?CairngormEvent?)?:? void
    {
    ????stockQuote.isPending?
    = ? true ;
    ?????????????
    ????var?stockQuoteEvent?:?GetStockQuoteEvent?
    = ?GetStockQuoteEvent(?event?);??????????
    ????var?symbol?:?String?
    = ?stockQuoteEvent.symbol;
    ????var?delegate?:?StockMarketDelegate?
    = ? new ?StockMarketDelegate(? this ?);
    ????delegate.getQuoteForSymbol(?symbol?);????
    }

    ????????
    public ?function?onResult(?event?:? * ? = ? null ?)?:? void
    {
    ????
    // for?demo?purpose:?event?would?normally?be?an?event?object?of?remote?service?result.????????????
    ????stockQuote.lastStockQuote? = ?event?as?Number;????????????
    ????stockQuote.isPending?
    = ? false ;
    ????stockQuote.statusMessage?
    = ? "" ;
    }

    ????????
    public ?function?onFault(?event?:? * ? = ? null ?)?:? void
    {
    ????stockQuote.lastStockQuote?
    = ?NaN;
    ????stockQuote.statusMessage?
    = ? " Quote?retrieval?error. " ;
    ????stockQuote.isPending?
    = ? false ;
    }

    最后看一下StockMarketPod.mxml的全部代碼

    <? xml?version="1.0"?encoding="utf-8" ?>
    < mx:Panel?
    ????
    xmlns:mx ="http://www.adobe.com/2006/mxml"
    ????xmlns:util
    ="com.adobe.cairngorm.samples.dashboard.util.*" >
    ????????
    ????
    < mx:Script >
    ????????
    <![CDATA[
    ????????????import?com.adobe.cairngorm.control.CairngormEventDispatcher;
    ????????????import?com.adobe.cairngorm.samples.dashboard.model.StockQuote;
    ????????????import?com.adobe.cairngorm.samples.dashboard.events.GetStockQuoteEvent;????
    ????????????
    ????????????[Bindable]
    ????????????public?var?stockQuote?:?StockQuote;
    ????????????
    ????????????private?function?getQuoteForSymbol()?:?void
    ????????????{
    ????????????????var?event?:?GetStockQuoteEvent?=?new?GetStockQuoteEvent(?symbolTextInput.text?);
    ????????????????CairngormEventDispatcher.getInstance().dispatchEvent(?event?);
    ????????????}
    ????????
    ]]>
    ????
    </ mx:Script >
    ????
    ????
    < mx:CurrencyFormatter?
    ????????????????
    id ="standardEuroFormatter" ??
    ????????currencySymbol
    ="$" ?precision ="2" />
    ????????
    ????
    < mx:StringValidator?
    ????????
    minLength ="2" ?triggerEvent ="change" ?
    ????????source
    ="{?symbolTextInput?}" ?property ="text"
    ????????valid
    ="stockQuote.validateSymbol(?true?);" ?
    ????????invalid
    ="stockQuote.validateSymbol(?false?);" />
    ????
    ????
    < mx:Form >
    ????
    ????????
    < mx:FormItem? label ="Symbol" >
    ????????????
    < mx:TextInput?
    ????????????????
    id ="symbolTextInput" />
    ????????????
    < mx:Button?
    ????????????????
    label ="Get?Quote" ?
    ????????????????enabled
    ="{?stockQuote.isValid?}" ?
    ????????????????click
    ="getQuoteForSymbol();" />
    ????????
    </ mx:FormItem >
    ????????????????
    ????????
    < mx:FormItem? label ="Price?Quote" >
    ????????????
    < mx:Label? text ="{?standardEuroFormatter.format(?stockQuote.lastStockQuote?)?}" />
    ????????????
    < mx:Label? text ="{?stockQuote.statusMessage?}" />
    ????????
    </ mx:FormItem >
    ????????
    ????
    </ mx:Form > ????
    </ mx:Panel >


    此視圖中我們不需要使用ModelLocator,而是使用StockQuote作為參數(shù)傳入StockMarketPod.mxml
    引用視圖的代碼

    < mx:Script >
    ????
    <![CDATA[
    ????????import?com.adobe.cairngorm.samples.dashboard.model.ModelLocator;
    ????????import?com.adobe.cairngorm.samples.dashboard.model.StockQuote;
    ????????????????????????????????????
    ????????[Bindable]
    ????????private?var?model?:?ModelLocator?=?ModelLocator.getInstance();
    ????????[Bindable]
    ????????private?var?stockQuote?:?StockQuote?=?model.stockQuote;????
    ????
    ]]>
    </ mx:Script >
    ?
    < view:StockMarketPod?
    ????
    stockQuote ="{?stockQuote?}" ?
    ????title
    ="Stockmarket?Pod" />

    ?

    只傳遞需要的信息給視圖是一個(gè)比較好的做法,而盡量少使用ModelLocator這樣的全局變量,這樣也使用視圖重用性更高。

    posted @ 2006-12-29 00:36 云自無(wú)心水自閑 閱讀(919) | 評(píng)論 (0)編輯 收藏

    上次介紹了如何在業(yè)務(wù)邏輯中改變視圖,這次講解一種新方法。我們的股票市場(chǎng)顯示圖將擴(kuò)展為多股票報(bào)價(jià)查詢器。我們將看到業(yè)務(wù)邏輯是怎么調(diào)整每個(gè)視圖的。而且我們還會(huì)接觸到無(wú)狀態(tài)命令是怎么使得事情變得簡(jiǎn)單。
    第三次迭代--創(chuàng)建業(yè)務(wù)邏輯管理多視圖
    我們經(jīng)常可以發(fā)現(xiàn)會(huì)有很多個(gè)類(lèi)型一樣的視圖,其背后的功能也非常類(lèi)似。每個(gè)視圖顯示一個(gè)Model對(duì)象。這些視圖可以在開(kāi)始時(shí)從管理對(duì)象處請(qǐng)求一個(gè)Model對(duì)象。比如:我們的StockMarketDashboard.mxml可以進(jìn)行這樣的添加:

    < view:StockMarketPod?
    ????
    quoteId ="quote1" ?
    ????title
    ="Stockmarket?first?pod" />
    < view:StockMarketPod?
    ????
    quoteId ="quote2" ?
    ????title
    ="Stockmarket?second?pod" />
    < view:StockMarketPod?
    ????
    quoteId ="quote3" ?
    ????title
    ="Stockmarket?third?pod" />
    < view:StockMarketPod?
    ????
    quoteId ="quote4" ?
    ????title
    ="Stockmarket?fourth?pod" />

    注意:視圖需要傳遞一些唯一的標(biāo)識(shí),我們將這些標(biāo)識(shí)添加到StockQuote類(lèi)。

    package ?org.nevis.cairngorm.samples.dashboard.model
    {
    ????
    public ? class ?StockQuote
    ????
    {
    ????????[Bindable]
    ????????
    public ?var?lastStockQuote?:?Number;
    ????????[Bindable]
    ????????
    public ?var?stockQuoteError?:?String;????????
    ????}

    }


    管理對(duì)象StockQuoteManager,在ModelLocator實(shí)例中初始化。但是StockQuoteManager會(huì)是一個(gè)怎樣的對(duì)象呢?
    通常我使用Hashmap來(lái)實(shí)現(xiàn),其鍵值就是視圖中的唯一標(biāo)識(shí)符。在構(gòu)造函數(shù)中我們可以初始化這個(gè)Hashmap,F(xiàn)lex2中我們使用flash.utils.Dictionary

    public ?function?StockQuoteManager()?
    {
    ????stockQuotes?
    = ? new ?Dictionary();
    }


    getStockQuote方法返回一個(gè)stockQuote對(duì)象

    public ?function?getStockQuote(?quoteId?:?String?)?:?StockQuote
    {
    ????var?key?:?String?
    = ?quoteId;
    ????
    if (?stockQuotes[?key?]? == ? null ?)
    ????
    {
    ????????var?stockQuote?:?StockQuote?
    = ? new ?StockQuote();
    ????????stockQuotes[?key?]?
    = ?stockQuote;
    ????}

    ????
    return ?StockQuote(?stockQuotes[?key?]?);
    }


    StockMarketPod.mxml幾乎沒(méi)有什么改動(dòng)。只需要將那個(gè)唯一的標(biāo)識(shí)符發(fā)送給命令,因?yàn)槊钚枰獜墓芾韺?duì)象處取得StockQuote對(duì)象。所以GetStockQuoteEvent類(lèi)多了一個(gè)quoteId屬性。
    在GetStockQuoteCommand中,需要將唯一標(biāo)識(shí)符保存在一個(gè)成員變量中

    private ?var?model?:?ModelLocator? = ?ModelLocator.getInstance();
    private ?var?quoteId?:?String;
    ?????????
    public ?function?execute(?event?:?CairngormEvent?)?:? void
    {
    ????var?stockQuoteEvent?:?GetStockQuoteEvent?
    = ?GetStockQuoteEvent(?event?);?????????????
    ????var?symbol?:?String?
    = ?stockQuoteEvent.symbol;
    ????quoteId?
    = ?stockQuoteEvent.quoteId;
    ????var?delegate?:?StockMarketDelegate?
    = ? new ?StockMarketDelegate(? this ?);
    ????delegate.getQuoteForSymbol(?symbol?);
    }

    ????????
    public ?function?onResult(?event?:?ResultEvent? = ? null ?)?:? void
    {
    ????
    // simulate?a?result?from?service
    ????var?lastStockQuote?:?Number? = ?Math.random()? * ? 50 ? + ? 5 ;
    ????var?stockQuote?:?StockQuote?
    = ?model.stockQuoteManager.getStockQuote(?quoteId?);
    ????stockQuote.lastStockQuote?
    = ?lastStockQuote;
    ????stockQuote.stockQuoteError?
    = ? "" ;
    }

    ????????
    public ?function?onFault(?event?:?FaultEvent? = ? null ?)?:? void
    {
    ????var?stockQuote?:?StockQuote?
    = ?model.stockQuoteManager.getStockQuote(?quoteId?);
    ????stockQuote.lastStockQuote?
    = ?NaN;
    ????stockQuote.stockQuoteError?
    = ? " An?error?occured. " ;
    }

    注意一下,在上面的代碼中我們使用的是無(wú)狀態(tài)命令,在Cairngorm的說(shuō)明中,無(wú)狀態(tài)命令是每次Cairngorm事件的響應(yīng)都創(chuàng)建一個(gè)新的命令實(shí)例的方式。因此,在這種方式中我們可以放心地把變量存儲(chǔ)在成員變量中,而不用擔(dān)心被其他人改變。

    posted @ 2006-12-28 00:50 云自無(wú)心水自閑 閱讀(721) | 評(píng)論 (0)編輯 收藏

    當(dāng)服務(wù)端或者客戶端的邏輯變化后,有很多種方法來(lái)更新視圖。我比較推薦使用ModelLocator策略,主要是使用Flex的綁定功能。
    通常你的視圖與ModelLocator的屬性綁定,這些屬性可以由命令或者其他的業(yè)務(wù)邏輯或者其他視圖所改變。而一旦這些屬性發(fā)生了變化,所有與它們綁定的視圖都隨之變化。
    因?yàn)楹芏嗟腃airngorm的例子都想做得淺顯易懂,因此經(jīng)常是簡(jiǎn)單地將這些屬性做為ModelLocator中的一個(gè)暴露給外界的成員變量。而當(dāng)Cairngorm的應(yīng)用變得龐大的時(shí)候,這往往是不夠的。在此我將會(huì)專(zhuān)門(mén)針對(duì)這個(gè)問(wèn)題展示一個(gè)例子。這個(gè)例子是一個(gè)股票市場(chǎng)的顯示表。
    第一次迭代:將應(yīng)用運(yùn)轉(zhuǎn)起來(lái)
    首先看一下Cairngorm所主張的MVC模式。目前股票市場(chǎng)顯示表將只包含一些簡(jiǎn)單的UI控制。點(diǎn)擊“GetQuote”來(lái)派發(fā)Cairngorm事件,調(diào)用命令來(lái)請(qǐng)求一個(gè)新報(bào)價(jià)。StockMarketPod.mxml中在Button的Click事件中派發(fā)Cairngorm事件。

    < mx:Button? label ="Get?Quote" ?click ="getQuoteForSymbol();" />

    相應(yīng)的腳本代碼:

    ?
    import?org.nevis.cairngorm.samples.dashboard.events.GetStockQuoteEvent;????????????????????????????????????
    private?function?getQuoteForSymbol()?:?void
    {
    ????var?event?:?GetStockQuoteEvent?
    =?new?GetStockQuoteEvent(?symbolTextInput.text?);
    ????dispatchEvent(?event?);
    }

    GetStockQuoteCommand響應(yīng)并處理這個(gè)Cairngorm事件,請(qǐng)求一個(gè)業(yè)務(wù)代理類(lèi)來(lái)報(bào)價(jià)。

    public?function?execute(?event?:?CairngormEvent?)?:?void
    {
    ????var?symbol?:?String?
    =?GetStockQuoteEvent(?event?).symbol;
    ????var?delegate?:?StockMarketDelegate?
    =?new?StockMarketDelegate(?this?);
    ????delegate.getQuoteForSymbol(?symbol?);
    }


    在實(shí)際情況中,需要進(jìn)行一個(gè)遠(yuǎn)程的服務(wù)器端的調(diào)用,在Demo中,為簡(jiǎn)化起見(jiàn),我注釋掉了遠(yuǎn)程調(diào)用的相關(guān)代碼。這里StockMarketDelegate.as只是對(duì)命令進(jìn)行回調(diào)。

    public?function?StockMarketDelegate(?responder?:?Responder?)
    {
    ????
    //disabled?for?demo
    ????
    //this.service?=?ServiceLocator.getInstance().getService(?"stockMarketDelegate"?);
    ????this.responder?=?responder;
    }

    ????????
    public?function?getQuoteForSymbol(?symbol?:?String?)?:?void
    {
    ????
    //disabled?for?demo
    ????
    //var?call?:?AsyncToken?=?service.getQuoteForSymbol(?symbol?);
    ????
    //call.resultHandler?=?responder.onResult;
    ????
    //call.faultHandler?=?responder.onFault;
    ????if(?symbol?==?"fail"?)
    ????
    {
    ????????responder.onFault();
    ????}

    ????
    else
    ????
    {
    ????????responder.onResult();
    ????}

    }

    我們的StockMarketPod視圖只需要兩條消息,
    1. 股票的報(bào)價(jià)
    2. 錯(cuò)誤消息
    因?yàn)楝F(xiàn)在是第一次迭代過(guò)程中,處理比較簡(jiǎn)單,因此使用ModelLocator的成員來(lái)解決。

    public?var?lastStockQuote?:?Number;
    public?var?stockQuoteError?:?String;


    在此Demo中,GetStockQuoteCommand命令模擬返回相應(yīng)的結(jié)果。

    public?function?onResult(?event?:?ResultEvent?=?null?)?:?void
    {
    ????
    //simulate?a?result?from?service
    ????var?stockQuote?:?Number?=?Math.random()?*?50?+?5;
    ????model.lastStockQuote?
    =?stockQuote;
    ????model.stockQuoteError?
    =?"";
    ?}

    ????????
    public?function?onFault(?event?:?FaultEvent?=?null?)?:?void
    {
    ????model.lastStockQuote?
    =?NaN;
    ????model.stockQuoteError?
    =?"An?error?occured.";
    }

    StockMarketPod視圖綁定這些成員并進(jìn)行一些格式化的處理。

    <mx:FormItem?label="Symbol">
    ????
    <mx:Label?text="{?formatQuote(?model.lastStockQuote?)?}"/>
    </mx:FormItem>
    <mx:FormItem>
    ????
    <mx:Label?text="{?model.stockQuoteError?}"/>
    </mx:FormItem>

    格式化函數(shù)的腳本

    private?function?formatQuote(?quote?:?Number?)?:?String
    {
    ????
    return?(?isNaN(?quote?)?)???""?:?String(?quote?);
    }


    現(xiàn)在我們來(lái)進(jìn)行重構(gòu)并將一些功能從視圖中抽取出來(lái)到一個(gè)可以進(jìn)行單元測(cè)試的工具類(lèi)中。

    第二次迭代,創(chuàng)建符合需求的業(yè)務(wù)邏輯
    現(xiàn)在我們已經(jīng)有一個(gè)可以運(yùn)行的最簡(jiǎn)單的應(yīng)用。當(dāng)你的應(yīng)用變得龐大后,將會(huì)有很多的限制。你會(huì)發(fā)現(xiàn)你的ModelLocator非常的臃腫,以致于有時(shí)候,你都找不到你所要的成員。甚至?xí)忻麤_突的事情發(fā)生。
    一個(gè)普通的重構(gòu)方法是封裝你的用例圖中的成員成為一個(gè)業(yè)務(wù)對(duì)象。這個(gè)業(yè)務(wù)對(duì)象能夠表達(dá)業(yè)務(wù)上下文中需要的視圖信息。你可以把業(yè)務(wù)對(duì)象設(shè)計(jì)得最適合用例圖的粒度。在一個(gè)大型的應(yīng)用中,你可能會(huì)設(shè)計(jì)一系列的業(yè)務(wù)對(duì)象來(lái)表達(dá)你的用例。你的視圖將會(huì)綁定這些對(duì)象或者這些對(duì)象的屬性上。通過(guò)這種方法,ModelLocator與其目標(biāo)之間的聯(lián)系更容易,開(kāi)發(fā)者更容易掌握業(yè)務(wù)邏輯所包含的內(nèi)容。
    在這個(gè)Demo中,我們可以把a(bǔ)stStockQuote和stockQuoteError這兩個(gè)成員封裝到一個(gè)業(yè)務(wù)對(duì)象中。

    package?org.nevis.cairngorm.samples.dashboard.model
    {
    ????
    public?class?StockQuote
    ????
    {
    ????????[Bindable]
    ????????
    public?var?lastStockQuote?:?Number;
    ????????[Bindable]
    ????????
    public?var?stockQuoteError?:?String;
    ????}

    }


    這樣在ModelLocator中,我們只需要定義一個(gè)成員
    public var stockQuote : StockQuote = new StockQuote ();
    我們的視圖也相應(yīng)修改為:

    <mx:FormItem?label="Symbol">
    ????
    <mx:Label?text="{?formatQuote(?model.stockQuote.lastStockQuote?)?}"/>
    </mx:FormItem>
    <mx:FormItem>
    ????
    <mx:Label?text="{?model.stockQuote.stockQuoteError?}"/>
    </mx:FormItem>

    posted @ 2006-12-27 01:31 云自無(wú)心水自閑 閱讀(1797) | 評(píng)論 (0)編輯 收藏

    1、www.FlashDevelop.com網(wǎng)站最近發(fā)布了FlashDevelop2.0.2,其中增加了對(duì)Flex2的支持。
    2、下面介紹一下使用的方法。我用的是一個(gè)筆記本,只有一個(gè)C盤(pán),所有安裝路徑都在C盤(pán)。
    3、首先是下載FlashDevelop2.0.2(以下簡(jiǎn)稱(chēng)FD),我安裝在c:\program files\flashdevelop目錄下。
    還要注意下載安裝JDK5,和.net framework1.1(這個(gè)程序是用C#開(kāi)發(fā)的)
    4、再下載Flex2 SDK,從www.flex.org的左上角可以找到,好象要在Adobe公司里注冊(cè)一下。
    下載完畢后,解壓縮,我是放在c:\flex_2_sdk目錄下。
    ? 運(yùn)行FD,按F9進(jìn)入程序設(shè)置,找到ASCompletion.Flex2SDK.Path這個(gè)選項(xiàng),把它的值設(shè)為SDK的路徑。
    我這里就是C:\Flex_2_SDK
    5、下載AS3 Intrinsic Classes URL Address我把它解壓縮在C:\Program Files\FlashDevelop\Library目錄下
    6、下載
    AS3 top-level declaration解壓縮在C:\Program Files\FlashDevelop
    在FD中的程序設(shè)置(Program Setting)中設(shè)置
    ASCompletion.Macromedia.Classpath的值為此路徑,
    設(shè)置
    ASCompletion.MTASC.UseStdClasses的值為False
    7、下載
    the MXML definition file這解壓縮在C:\Program Files\FlashDevelop\Data目錄下

    到此步驟,F(xiàn)D的安裝基本告一段落。

    下面就可以新建項(xiàng)目了,為方便起見(jiàn)
    8、下載項(xiàng)目模板 http://www.bit-101.com/flashdevelop/ProjectTemplates.zip,解壓縮到C:\Program Files\FlashDevelop\Data\ProjectTemplates目錄下。
    9、重新啟動(dòng)FD,新建項(xiàng)目,選擇Flex模板。在右邊會(huì)看到deploy、html_template, src三個(gè)目錄和build.properties, build.xml兩個(gè)文件,src目錄下有一個(gè)app.mxml的空文件。
    至此,項(xiàng)目的目錄框架搭建完成。下面就是要編譯生成SWF文件了。

    10、對(duì)于編譯生成SWF文件有好幾種方式,在此介紹兩種,一種是FD開(kāi)發(fā)者提供了,使用MSASC,一種是使用Ant。第一種速度奇塊,但是設(shè)置比較復(fù)雜,第二種速度較慢,比較方便。
    11、如果使用第一種,就需要在每個(gè)文件的頭部添加?xùn)|西
    AS文件頭添加
    /**
    * @mxmlc -default-size 400 300 -incremental=true
    */
    mxml文件頭添加
    <!-- @mxmlc -default-size 400 300 -incremental=true -->
    12、如果是用第二種方法,首先要裝Ant,這個(gè)大家可能都有。
    13、然后修改Build.properties文件,把里面的一些路徑改一下。比如:flex2.dir
    14、然后到C:\Program Files\FlashDevelop\Settings目錄下找到Toolbar.xml
    添加一行
    <button label="ANT Build" click="PluginCommand" image="54" tag="Run;SaveAll;ant" shortcut="F7" />
    15、重新啟動(dòng)FD,在工具條上看見(jiàn)多了一個(gè)圖標(biāo),直接點(diǎn)這個(gè)按鈕,或者按F7,就可以調(diào)用Ant生成SWF文件了。而且Swf文件的顯示就是在FD集成環(huán)境里面的。第一種方式是在外部啟動(dòng)一個(gè)IE顯示Swf的。

    posted @ 2006-12-23 02:42 云自無(wú)心水自閑 閱讀(5193) | 評(píng)論 (0)編輯 收藏

    現(xiàn)在最新的版本是2.02, 主頁(yè): http://www.ariaware.com
    ?
    結(jié)構(gòu)框架圖:



    images\ebx_144215778.jpg

    看得出: 這個(gè)框架與Cairngorm非常的相似, 但是進(jìn)行了相當(dāng)?shù)暮?jiǎn)化.

    Controller + Command + ServiceLocator 這三駕馬車(chē)還在.
    Cairngrom中的Model, EventDispatcher, Delegate都不存在了.
    ViewHelper和ViewLocator被ArpForm所取代.
    對(duì)于初學(xué)者來(lái)說(shuō),這個(gè)簡(jiǎn)化版的可能更容易被接受吧.

    posted @ 2006-12-16 02:02 云自無(wú)心水自閑 閱讀(1186) | 評(píng)論 (0)編輯 收藏

    僅列出標(biāo)題
    共29頁(yè): First 上一頁(yè) 20 21 22 23 24 25 26 27 28 下一頁(yè) Last 
    主站蜘蛛池模板: 久久精品免费一区二区| 日日躁狠狠躁狠狠爱免费视频| a毛片免费全部播放完整成| 免费人成年激情视频在线观看| 亚洲综合色丁香婷婷六月图片| 成人AV免费网址在线观看| 亚洲日本久久一区二区va| 一二三四视频在线观看中文版免费| 亚洲18在线天美| 日韩免费电影在线观看| 美女被免费网站视频在线| 久久青青草原亚洲av无码| 最新国产乱人伦偷精品免费网站| 亚洲av永久无码精品古装片| 一级特黄aa毛片免费观看| 亚洲一区在线免费观看| 国产色爽免费视频| 一级A毛片免费观看久久精品| 亚洲综合精品网站| 久久青草91免费观看| 国产精品亚洲精品| 国产男女猛烈无遮挡免费网站 | 亚洲春黄在线观看| 999国内精品永久免费观看| 亚洲依依成人亚洲社区| 免费一级毛片正在播放| a级毛片免费全部播放无码| 亚洲资源在线视频| 国产精品久久免费视频| 黄色网站软件app在线观看免费 | 亚洲处破女AV日韩精品| 91精品免费国产高清在线| 亚洲hairy多毛pics大全| 亚洲综合无码精品一区二区三区 | 中文字幕乱码免费看电影| 亚洲熟妇无码爱v在线观看| 国产精品免费看久久久无码| 中文字幕免费人成乱码中国| 亚洲一本之道高清乱码| 国产精品亚洲美女久久久| 1000部拍拍拍18勿入免费凤凰福利|