/** {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, final Map<String, Object> context) { String chartUrl = ResourceProviderServlet.computeLocalResourceDownloadUrl( getChartDescriptor().getUrl(), true); String chartData = getJdbcTemplate() .execute( new ConnectionCallback<String>() { @Override public String doInConnection(Connection con) throws SQLException { return getChartDescriptor() .getData( getChartModel(context), con, getTranslationProvider(context), getLocale(context)); } }); IResource resource; try { resource = new MemoryResource( null, "text/xml", StringUtils.prependUtf8Bom(chartData).getBytes(StandardCharsets.UTF_8.name())); } catch (UnsupportedEncodingException ex) { throw new ActionException(ex); } String resourceId = ResourceManager.getInstance().register(resource); Map<String, String> flashContext = new LinkedHashMap<>(); Dimension d = getChartDescriptor().getDimension(); flashContext.put("chartWidth", Integer.toString(d.getWidth() - 20)); flashContext.put("chartHeight", Integer.toString(d.getHeight() - 100)); flashContext.put("dataURL", ResourceProviderServlet.computeDownloadUrl(resourceId)); List<G> chartActions = new ArrayList<>(); for (IDisplayableAction action : getActions()) { IView<E> view = getView(context); chartActions.add( getActionFactory(context).createAction(action, actionHandler, view, getLocale(context))); } getController(context) .displayFlashObject( chartUrl, flashContext, chartActions, getTranslationProvider(context) .getTranslation(getChartDescriptor().getTitle(), getLocale(context)), getSourceComponent(context), context, d, false); return super.execute(actionHandler, context); }
/** * Do write active resource. * * @param resource the resource * @param outputStream the output stream * @throws IOException the IO exception */ protected void doWriteActiveResource(IActiveResource resource, OutputStream outputStream) throws IOException { super.writeActiveResource(resource, outputStream); }