1 16 package org.apache.jetspeed.tutorial.modules.actions.portlets; 17 18 import org.apache.turbine.util.Log; 20 import org.apache.turbine.util.RunData; 21 import org.apache.turbine.services.TurbineServices; 22 23 import org.apache.jetspeed.portal.Portlet; 25 import org.apache.jetspeed.modules.actions.portlets.JspPortletAction; 26 import org.apache.jetspeed.webservices.finance.stockmarket.StockQuoteService; 27 import org.apache.jetspeed.webservices.finance.stockmarket.StockQuote; 28 import org.apache.jetspeed.util.PortletConfigState; 29 import org.apache.jetspeed.util.PortletSessionState; 30 import org.apache.jetspeed.util.StringUtils; 31 32 38 public class TutorialStockQuoteAction8 extends JspPortletAction 39 { 40 private static final String SYMBOLS = "symbols"; 41 private static final String COLUMNS = "columns"; 42 private static final String QUOTES = "quotes"; 43 private static final String [] ALL_COLUMNS = {"Symbol","Price","Change","Volume"}; 44 45 51 protected void buildNormalContext(Portlet portlet, 52 RunData rundata) 53 { 54 try 55 { 56 StockQuoteService service = (StockQuoteService) TurbineServices.getInstance(). 58 getService(StockQuoteService.SERVICE_NAME); 59 60 String symbols = (String ) PortletSessionState.getAttributeWithFallback(portlet, rundata, SYMBOLS); 62 63 String [] symbolArray = StringUtils.stringToArray(symbols, ","); 65 StockQuote[] quotes = service.fullQuotes(symbolArray); 66 67 rundata.getRequest().setAttribute(QUOTES, quotes); 69 rundata.getRequest().setAttribute(COLUMNS, ALL_COLUMNS); 70 } 71 catch (Exception e) 72 { 73 Log.error(e); 74 } 75 } 76 } 77 78 | Popular Tags |