Итак, вот код, который у меня есть до сих пор:
Гибкий код
<?xml version="1.0" encoding="utf-8"?>
<fx:Declarations>
<s:RemoteObject id="getStockPrices" result="result(event)" destination="blazeDsService"
endpoint="http://localhost:8400/flexspring/messagebroker/streamingamf"/>
</fx:Declarations>
<mx:DataGrid x="10" y="295" width="910" height="211" creationComplete="getStockPrices.getQuotes();"
dataProvider="{getStockPrices.getQuotes.lastResult}" >
<mx:columns>
<mx:DataGridColumn headerText="Stock Ticker" dataField="name" />
<mx:DataGridColumn headerText="Price" dataField="price"/>
<mx:DataGridColumn headerText="Hi" dataField="col3"/>
<mx:DataGridColumn headerText="Low" dataField="col4"/>
<!--<mx:DataGridColumn headerText="Adverage" dataField="col5"/>
<mx:DataGridColumn headerText="Graph" dataField="col6"/>-->
</mx:columns>
</mx:DataGrid>
<mx:Button label="Retrieve Stocks" click="retrieveStocks()"/>
И это файл класса java. Это возвращает и arraylist:
package flex;
импортировать java.util.ArrayList; импортировать java.util.List; импортировать java.util.Random;
импортировать org.springframework.flex.remoting.RemotingDestination; импортировать org.springframework.flex.remoting.RemotingInclude; импортировать org.springframework.stereotype.Service;
импортировать supportClasses.StockQuote;
@Обслуживание
@RemotingDestination
открытый класс BlazeDsService {
private static final String[] MASTER_LIST = {"C", "FNM", "FRE", "F", "GOOG", "AIG", "CSCO", "MSFT", "AAPL", "YHOO", "BSX", "PORT","F", "TNT", "ESP", "RET", "VBN", "EES"};
@RemotingInclude
public List<StockQuote> getQuotes(){
List<StockQuote> list = new ArrayList<StockQuote>();
Random r = new Random();
for (String s:MASTER_LIST){
StockQuote sq = new StockQuote();
sq.setName(s);
sq.setPrice(r.nextInt(50));
list.add(sq);
}
return list;
}
}
В минуту нужно нажать кнопку, чтобы обновить данные. Я хочу избавиться от этого и опрашивать информацию каждые x секунд. Можно ли это сделать?
Нужно ли мне менять настройки? создать шаблон публикации-подписки и использовать потоковые каналы?
Спасибо