cancel
Showing results for 
Search instead for 
Did you mean: 

download file on button action

Former Member
0 Kudos

Hi all,

I want to download a word document template when i click a download button but not using file download element.can anyone suggest me how to do this?

Regards,

Anusha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

See the following thread.

Thanks,

Prasanthi.

Former Member
0 Kudos

Hi Prasanthi,

I have tried the code in the thread


final byte[] content = WDWebResource.getWebResource(content,WDWebResourceType.UNKNOWN);
final IWDCachedWebResource resource =WDWebResource.getWebResource(content, WDWebResourceType.UNKNOWN);
try {
final IWDWindow window =wdComponentAPI.getWindowManager().createExternalWindow(resource.getAbsoluteURL(),"Window title",	false);
window.open();
} catch (Exception e) {
wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(e),false);
}

But its showing the error that "type mismatch::cannot convert from iwdcachewebresource to byte array"

Regards,

Anusha

former_member192434
Active Contributor
0 Kudos

Hi

That's becouse of you are passing iwdcachewebresource as a byte parameter of method, in the given code u are storing it into byte [].

To get it done both sould be byte[] type. or byte only

Thanks

Answers (3)

Answers (3)

Former Member
0 Kudos

You can use the code that gets file from server.. Without using File download UI element


IWDResource resource;
    String name = <file name>;
    String path = <path> + name;
	InputStream stream;
	try {
		stream = new FileInputStream(path);
		resource = WDResourceFactory.createResource( stream, name, 
						WDWebResourceType.UNKNOWN, true);
		stream.close();
		wdComponentAPI.getWindowManager()
					.createNonModalExternalWindow( resource.getUrl( 0), name).show();
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

vinod

Former Member
0 Kudos
former_member192434
Active Contributor
0 Kudos