1 16 package org.apache.jetspeed.tutorial.modules.actions.portlets; 17 18 import org.apache.jetspeed.portal.portlets.VelocityPortlet; 19 20 import org.apache.turbine.util.Log; 22 import org.apache.turbine.util.RunData; 23 import org.apache.turbine.services.TurbineServices; 24 25 import org.apache.velocity.context.Context; 27 28 import org.apache.jetspeed.portal.portlets.VelocityPortlet; 30 import org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction; 31 import org.apache.jetspeed.webservices.finance.stockmarket.StockQuoteService; 32 import org.apache.jetspeed.webservices.finance.stockmarket.StockQuote; 33 import org.apache.jetspeed.util.PortletConfigState; 34 import org.apache.jetspeed.util.StringUtils; 35 36 42 public class TutorialStockQuoteAction1 extends VelocityPortletAction 43 { 44 private static final String SYMBOLS = "symbols"; 45 private static final String COLUMNS = "columns"; 46 private static final String QUOTES = "quotes"; 47 private static final String [] ALL_COLUMNS = {"Symbol","Price","Change","Volume"}; 48 49 56 57 protected void buildNormalContext(VelocityPortlet portlet, 58 Context context, 59 RunData rundata) 60 { 61 try 62 { 63 StockQuoteService service = (StockQuoteService) TurbineServices.getInstance(). 65 getService(StockQuoteService.SERVICE_NAME); 66 67 String symbols = PortletConfigState.getParameter(portlet, rundata, SYMBOLS, "IBM,MSFT,ORCL,SUNW"); 69 70 String [] symbolArray = StringUtils.stringToArray(symbols, ","); 72 StockQuote[] quotes = service.fullQuotes(symbolArray); 73 74 context.put(QUOTES, quotes); 76 context.put(COLUMNS, ALL_COLUMNS); 77 } 78 catch (Exception e) 79 { 80 Log.error(e); 81 } 82 } 83 } 84 85 | Popular Tags |