cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot open a new window with a IWDResource

Former Member
0 Kudos

Hello,

I need to create an Excel file with the data of a table in Web Dynpro. I used POI library and the code to generate and open the resource is the following:



ByteArrayOutputStream outputStream = null;
HSSFWorkbook wb = null;
HSSFSheet sheet = null;
	
try{
		
	outputStream = new ByteArrayOutputStream();
	wb = new HSSFWorkbook();
	sheet = wb.createSheet("Compensació Ingressos");
		
		
	//se definen los estilos de las celdas
		
	HSSFCellStyle style = wb.createCellStyle();
	style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
	style.setFillForegroundColor(HSSFColor.ORANGE.index);
	style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
	style.setBorderBottom((short)1);
	style.setBorderLeft((short)1);
	style.setBorderRight((short)1);
	style.setBorderTop((short)1);
	
	HSSFCellStyle style2 = wb.createCellStyle();
	style2.setBorderBottom((short)1);
	style2.setBorderLeft((short)1);
	style2.setBorderRight((short)1);
	style2.setBorderTop((short)1);
		
                int col = 0;
			
	//cabeceras
	
	HSSFRow fila = sheet.createRow(0);
	HSSFCell columna = fila.createCell((short)col++);
	HSSFRichTextString text = new HSSFRichTextString("DATA");
	columna.setCellStyle(style);
	columna.setCellValue(text);
		
	columna = fila.createCell((short)col++);
	text = new HSSFRichTextString("NÚM. DOCUMENT");
	columna.setCellStyle(style);
	columna.setCellValue(text);
				
	columna = fila.createCell((short)col++);
	text = new HSSFRichTextString("IMPORT");
	columna.setCellStyle(style);
	columna.setCellValue(text);
		
	columna = fila.createCell((short)col++);
	text = new HSSFRichTextString("PROJECTE");
	columna.setCellStyle(style);
	columna.setCellValue(text);
		
	columna = fila.createCell((short)col++);
	text = new HSSFRichTextString("GRUP DISPONIBILITAT");
	columna.setCellStyle(style);
	columna.setCellValue(text);
		
	columna = fila.createCell((short)col++);
	text = new HSSFRichTextString("DEUTOR");
	columna.setCellStyle(style);
	columna.setCellValue(text);
		
	//datos
	
	java.text.Format f = new SimpleDateFormat("dd/MM/yyyy");

	for(int x=0; x<wdContext.nodeCompensacioIng().size(); x++)
	{
		col=0;
		HSSFRow row = sheet.createRow(x+1);
		IPrivateCompensacioIngressosView.ICompensacioIngElement element = wdContext.nodeCompensacioIng().getCompensacioIngElementAt(x);
		HSSFCell cell = row.createCell((short)col++);
		HSSFRichTextString richText = new HSSFRichTextString(f.format(element.getData()));
		cell.setCellStyle(style2);
		cell.setCellValue(richText);
		cell = row.createCell((short)col++);
		richText = new HSSFRichTextString(element.getNumDoc());
		cell.setCellStyle(style2);
		cell.setCellValue(richText);
		cell = row.createCell((short)col++);
		cell.setCellStyle(style2);
		cell.setCellValue(element.getImport().doubleValue());
		cell = row.createCell((short)col++);
		richText = new HSSFRichTextString(element.getProjecte());
		cell.setCellStyle(style2);
		cell.setCellValue(richText);
		cell = row.createCell((short)col++);
		richText = new HSSFRichTextString(element.getGrup());
		cell.setCellStyle(style2);
		cell.setCellValue(richText);
		cell = row.createCell((short)col++);
		richText = new HSSFRichTextString(element.getDeutor());
		cell.setCellStyle(style2);
		cell.setCellValue(richText);
	}
	wb.write(outputStream);
		
	outputStream.close();
		
	byte[] by = outputStream.toByteArray();
		
	wdContext.currentContextElement().setXSLContent(by);

	IWDResource resource = WDResourceFactory.createResource(by,"Excel",WDWebResourceType.XLS);
	
	IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getUrl(WDFileDownloadBehaviour.AUTO.ordinal()), "Excel");
		
	window.open();
		
			
}
catch ( Exception ex ) {
	ex.printStackTrace();
	
}

This code worked fine until one day I get the following error:

application Processing HTTP request to servlet finished with error. The error is: com.sap.tc.webdynpro.services.sal.core.DispatcherException: Wrong Web Dynpro URL: "../WebDynpro/Servlet//xx?..". xx is not allowed without exchange key. Retrieved URI path: /sap.com/tcsecumewdconfig/UMEConfigToolPortalApp/~wd_key8_1229930863198/dataSourceConfiguration.dtd.

at com.sap.tc.webdynpro.serverimpl.wdc.adapter.HttpRequestAdapter.checkApplicationUri(HttpRequestAdapter.java:111)

And the new window with the Excel is not opened.

Any idea of what might be happening?

Thank you very much.

Edited by: Mireia Romo on Dec 22, 2008 5:16 AM

Accepted Solutions (0)

Answers (2)

Answers (2)

tom_parle3
Explorer
0 Kudos

Can you explain what the workaround was? I am getting a similar error in some test code.

Thanks,

Tom

Former Member
0 Kudos

I did a workaround