Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Using export functions in Server side

$
0
0
private class MenuClickHandler implements com.smartgwt.client.widgets.menu.events.ClickHandler {
private String exportFormat;
private final String exportFileName;
private final Object source;
private final FacetChart chart;

public MenuClickHandler(String exportFormat,String exportFileName, Object source, FacetChart chart) {
this.exportFormat = exportFormat;
this.exportFileName = exportFileName;
this.source = source;
this.chart = chart;
}

public void onClick(MenuItemClickEvent event) {
DSRequest requestProperties = new DSRequest();
requestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
requestProperties.setExportFilename(exportFileName + "_" + dateFormat.format(new Date()));
requestProperties.setExportImageQuality(1.0);
if (source != null && source instanceof MetricsPanel && ((MetricsPanel) source).getChartData().length < 1){
SC.warn(APIConstants.NO_DATA_TO_EXPORT);
return;
}

if (exportFormat.equalsIgnoreCase(ExportImageFormat.PNG.toString()) || exportFormat.equalsIgnoreCase(ExportImageFormat.JPEG.toString())) {
requestProperties.setExportImageFormat(EnumUtil.getEnum(ExportImageFormat.values(), exportFormat));
RPCManager.exportImage(chart.getSvgString(), requestProperties);
} else if(exportFormat.trim().equalsIgnoreCase(ExportFormat.CSV.toString())){
MetricsPanel sourceRef;
if(source == null || ! (source instanceof MetricsPanel)) {
SC.warn(APIConstants.EXPORT_WARN);
return;//do nothing
} else {
sourceRef = (MetricsPanel) source;
}
requestProperties.setExportAs(ExportFormat.CSV);
DataSource.exportClientDataStatic(sourceRef.getChartData(), requestProperties);
} else if(exportFormat.trim().equalsIgnoreCase("pdf")){
//default option is pdf
RPCManager.exportContent(chart.getParentCanvas(), requestProperties);
}
}
}

We populate the data used in chart from server.

We have the above code in the client side we want this to be done in server side as well. I saw some recommendation to use class in isomorphic_core_rpc.jar. But the class in them are different.

Is pdf ,image export is possible though isomorphic_core_rpc.jar classes ?

Viewing all articles
Browse latest Browse all 4756

Trending Articles