cancel
Showing results for 
Search instead for 
Did you mean: 

FileDownload implementation not working

Former Member
0 Kudos
37

Hi,

I am trying to implement a file control which is not working. I have done the following.

I have mapped the data attribute to a context node of type binary.

The content of the file is String array. I have converted the contents to byte and assigned it to data node. But I think the data node should not be assigned the content it is a place holder for the data while downloading. So I have tried by assigning data as well as without it.

And following mappping has been done in code

IWDModifiableBinaryType binaryTypeDownload;

IWDAttributeInfo attInfo = wdContext.nodeConfigFiles().getNodeInfo().getAttribute("DownloadData");

ISimpleTypeModifiable type1 = attInfo.getModifiableSimpleType();

binaryTypeDownload = (IWDModifiableBinaryType) type1;

binaryTypeDownload.setMimeType(new WDWebResourceType(type,"",false));

binaryTypeDownload.setFileName(FileNameSelected);

It gives me this exception :

com.sap.tc.webdynpro.progmodel.context.ContextException: MappedAttributeInfo(DetailsView.Device1.ConfigFiles.DownloadData): must not modify the datatype of a mapped attribute

Please help.

Regards,

Parminder

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

The attribute is mapped to the controller context and you are trying to change it in the view context.

Create a seperate attribute in view and do this or you can write this piece of code in the controller.

Regards

Bharathwaj

Former Member
0 Kudos

Hi Bharathwaj,

The exception problem got solved.Thanks a lot. But I have one more doubt. We are just providing the name of the file and its type to binaryTypeDownload. And now when I click on the download link nothing happens. I want to know from where it will pick the file and the contents. Something is still missing in my implementation.

Regards,

Parminder

Former Member
0 Kudos

Hi,

You have to use FileInputStream in java to fetch the data from the server.

<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileInputStream.html">File Input Stream API</a>

<filestreamobject>.read(bytedata);

"bytedata".. is of type byte , "bytedata" will have the data ..

This will give you a binary value which you set to this a value attribute. After this , onCLick of the downlaod element..you can download the file.

Regards

Bharathwaj

Former Member
0 Kudos

Content should be available as byte[] array from

wdContext.currentConfigFilesElement().getDownloadData();

VS

Former Member
0 Kudos

Hi Bharathwaj,

I am doing the following,

Reading the data in byte array :

*******************************************

FileInputStream istr = new FileInputStream(configFile);

BufferedInputStream bstr = new BufferedInputStream( istr ); // promote

int size = (int) configFile.length(); // get the file size (in bytes)

byte[] data = new byte[size]; // allocate byte array of right size

bstr.read( data, 0, size ); // read into byte array

bstr.close();

wdContext.nodeDevice1().nodeConfigFiles().currentConfigFilesElement().setFileContent(data);

*************************************************

And the setting it into the context node

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

String type = FileNameSelected.substring(count);

content = wdContext.nodeConfigFiles().currentConfigFilesElement().getFileContent();

wdContext.nodeDevice1().nodeConfigFiles().currentConfigFilesElement().setDownloadData(content);

IWDAttributeInfo attInfo = wdContext.nodeConfigFiles().getNodeInfo().getAttribute("Binary");

binaryTypeDownload = (IWDModifiableBinaryType) attInfo.getModifiableSimpleType();

binaryTypeDownload.setMimeType(new WDWebResourceType(type,"",false));

binaryTypeDownload.setFileName(FileNameSelected);

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

DownloadData is the context node mapped to the data attribute of control.

I get an illegal argument exception .

Please suggest.

Regards,

Parminder

Message was edited by: Parminder Kaur

Former Member
0 Kudos

Hi,

Edit these lines and check.

binaryTypeDownload.setMimeType(WDWebResourceType.<give the file type>)

binaryTypeDownload.setFileName(FileNameSelected);

Regards

Bharathwaj

Former Member
0 Kudos

Hi Parminder,

We need to have just one binary attribute to make the FileDownload work. From your code, it seems you

are using three binary attributes, all under the node 'ConfigFiles' :

1) <i>fileContent</i>

wdContext.nodeDevice1().nodeConfigFiles().currentConfigFilesElement().setFileContent(data);

2) <i>DownloadData</i>

wdContext.nodeDevice1().nodeConfigFiles().currentConfigFilesElement().setDownloadData(content);

3) <i>Binary</i>

IWDAttributeInfo attInfo = wdContext.nodeConfigFiles().getNodeInfo().getAttribute("Binary");

Instead if you stick to one attribute, say 'DownloadData', your code should look something like:

*******************************************

FileInputStream istr = new FileInputStream(configFile);

BufferedInputStream bstr = new BufferedInputStream( istr ); // promote

int size = (int) configFile.length(); // get the file size (in bytes)

byte[] data = new byte[size]; // allocate byte array of right size

bstr.read( data, 0, size ); // read into byte array

bstr.close();

wdContext.nodeDevice1().nodeConfigFiles().currentConfigFilesElement().setDownloadData(data);

*************************************************

And the setting it into the context node

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

String type = FileNameSelected.substring(count);

IWDAttributeInfo attInfo = wdContext.nodeConfigFiles().getNodeInfo().getAttribute("DownloadData");

// make sure the attribute name is in correct case

binaryTypeDownload = (IWDModifiableBinaryType) attInfo.getModifiableSimpleType();

binaryTypeDownload.setMimeType(new WDWebResourceType(type,"",false));

binaryTypeDownload.setFileName(FileNameSelected);

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

If the mimetype being set is not proper, by default it would take the html format. So it shouldn't throw an error if the mimetype being set is not proper.

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Hi,

I tried to set it to WDWebResourceType.UNKNOWN . But still same exception.

Regards,

Parminder

Former Member
0 Kudos

Hi Nibu,

I have changed it two as if I use only one it gives me exception :

Mapped attribute data type can not be modified.

at this line

IWDAttributeInfo attInfo = wdContext.nodeConfigFiles().getNodeInfo().getAttribute("Binary");

Regards,

Parminder

Former Member
0 Kudos

Hi,

1. Stack trace and line number plz!

Regards

Bharathwaj

Former Member
0 Kudos

Hi,

Following is the stack trace :

java.lang.IllegalArgumentException

at com.sap.dictionary.runtime.DdTypeBinary.format(DdTypeBinary.java:62)

at com.sap.tc.webdynpro.clientserver.data.DataContainer.doFormat(DataContainer.java:1372)

at com.sap.tc.webdynpro.clientserver.data.DataContainer.getAndFormat(DataContainer.java:1066)

at com.sap.tc.webdynpro.clientserver.data.DataContainer.getAndFormat(DataContainer.java:1038)

at com.sap.tc.webdynpro.clientimpl.html.uielib.standard.uradapter.FileDownloadAdapter.getReference(FileDownloadAdapter.java:260)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.LinkRenderer.render(LinkRenderer.java:45)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.FlowLayoutRenderer.renderFlowLayoutItemFragment(FlowLayoutRenderer.java:252)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.FlowLayoutRenderer.renderFlowLayoutFragment(FlowLayoutRenderer.java:193)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.FlowLayoutRenderer.render(FlowLayoutRenderer.java:41)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.renderScrollContainerFragment(ScrollContainerRenderer.java:516)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.render(ScrollContainerRenderer.java:61)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.TabStripRenderer.renderTabStripItemContentFragment(TabStripRenderer.java:1555)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.TabStripRenderer.renderTabStripFragment(TabStripRenderer.java:644)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.TabStripRenderer.render(TabStripRenderer.java:61)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutCellFragment(GridLayoutRenderer.java:739)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutRowFragment(GridLayoutRenderer.java:388)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutFragment(GridLayoutRenderer.java:310)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.render(GridLayoutRenderer.java:71)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.TrayRenderer.renderTrayFragment(TrayRenderer.java:2233)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.TrayRenderer.render(TrayRenderer.java:71)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.FlowLayoutRenderer.renderFlowLayoutItemFragment(FlowLayoutRenderer.java:252)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.FlowLayoutRenderer.renderFlowLayoutFragment(FlowLayoutRenderer.java:193)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.FlowLayoutRenderer.render(FlowLayoutRenderer.java:41)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.renderScrollContainerFragment(ScrollContainerRenderer.java:516)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.render(ScrollContainerRenderer.java:61)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ViewContainerRenderer.renderViewContainerFragment(ViewContainerRenderer.java:118)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ViewContainerRenderer.render(ViewContainerRenderer.java:41)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutCellFragment(GridLayoutRenderer.java:739)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutRowFragment(GridLayoutRenderer.java:388)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutFragment(GridLayoutRenderer.java:310)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.render(GridLayoutRenderer.java:71)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.renderScrollContainerFragment(ScrollContainerRenderer.java:667)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.render(ScrollContainerRenderer.java:61)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ViewContainerRenderer.renderViewContainerFragment(ViewContainerRenderer.java:118)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ViewContainerRenderer.render(ViewContainerRenderer.java:41)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ViewContainerRenderer.renderViewContainerFragment(ViewContainerRenderer.java:118)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ViewContainerRenderer.render(ViewContainerRenderer.java:41)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutCellFragment(GridLayoutRenderer.java:739)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutRowFragment(GridLayoutRenderer.java:388)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutFragment(GridLayoutRenderer.java:310)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.render(GridLayoutRenderer.java:71)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.renderScrollContainerFragment(ScrollContainerRenderer.java:516)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.render(ScrollContainerRenderer.java:61)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutCellFragment(GridLayoutRenderer.java:739)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutRowFragment(GridLayoutRenderer.java:388)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutFragment(GridLayoutRenderer.java:310)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.render(GridLayoutRenderer.java:71)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.renderScrollContainerFragment(ScrollContainerRenderer.java:667)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.render(ScrollContainerRenderer.java:61)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutCellFragment(GridLayoutRenderer.java:739)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutRowFragment(GridLayoutRenderer.java:388)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.renderGridLayoutFragment(GridLayoutRenderer.java:310)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.GridLayoutRenderer.render(GridLayoutRenderer.java:71)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.renderScrollContainerFragment(ScrollContainerRenderer.java:667)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.render(ScrollContainerRenderer.java:61)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.UiWindowRenderer.render(UiWindowRenderer.java:45)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)

at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)

at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.sendHtml(HtmlClient.java:555)

at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.sendResponse(HtmlClient.java:346)

at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.sendResponse(HtmlClient.java:255)

at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.retrieveData(HtmlClient.java:157)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:425)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:649)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)

at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:248)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)

at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)

at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)

at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:160)

Regards,

Parminder

Former Member
0 Kudos

Hi Parminder,

I am extremely sorry for misleading you. I had read only the last post of yours and hence didn't know that you are using a mapped attribute. So, now you need to have atleast two attributes, else you need to write these lines of code in your component controller.

I am sorry

Best Regards,

Nibu.

Former Member
0 Kudos

All elements used for storing data are of type "binary" ?

Former Member
0 Kudos

Hi,

Yes , all elements used for storing data are of type binary.

Regards,

Parminder

Former Member
0 Kudos

Strange ! Somewhere you have missed some mapping or some type setting !

Do this.. !

1. Create a byte array using a string. say <some string>.getBytes().

2. Set this to a value attribute(binary) outside the node.

3.Map this to the FileDownlaod element.

4.Set the MIME type as TXT.

Is it working correctly.?

<b>

Make the attribute "FileContent" also as simpletype modifiable as you did for "DownloadContent"</b>

Regards

Bharathwaj

Former Member
0 Kudos

Hi,

I just did exactly the same but still same problem.

Regards,

Parminder

Former Member
0 Kudos

Did you try my other suggestion of giving a string as byte input and testing.

Are you seeing the string being opened in a notepad file.

Just some questions !

Why is this binary attribute mapped to controller

context?

Former Member
0 Kudos

Hi,

I tried the other suggestion also. But still on clicking of FileDownload Control I get the same exception.

Also I am not using the FileContent attribute now. I have just two .

1. Binary -

IWDAttributeInfo attInfo = wdContext.nodeConfigFiles().getNodeInfo().getAttribute("Binary");

- Type Binary and it is in View Context.

2. DownloadData :

type binary

It is getting populated in Component controller where I assign it a byte array and in View the DownloadData mapped to this DownloadData (in comp controller) is assigned to data attribute of download Control.

Regards,

Parminder

Former Member
0 Kudos

Hi,

FileDownload is very simple.There must be something really silly missing here.

Hmmm. I will tell you how it works. It might be easier for you debug it yourself.

FileDownload :

1. The UI Element data should be mapped to a attribute of type binary

2. This attribute should be of <b>IWDModifiableBinaryType</b>.

3. The FileDownload UI shows whatever binary (bytes) are stored in the format specified in the MIME TYPE.

So when you have these three conditions met with some binary data available , the FileDownload element should and will work.

Check if all these conditions are met.To avoid confusion, delete all attributes.Start from scratch , create a valueattribute in the view context and do the steps i have told.

Also use this for reference. <a href="http://help.sap.com/saphelp_nw04/helpdata/en/c8/32cc6922fb6040a768652aaa0b6879/frameset.htm">FileDownload API</a>

Now see if it works. Please don't use data from controller context. Have <b>only one variable directly in view 's context</b> and check.

Regards

Bharathwaj

Former Member
0 Kudos

Hi,

I tried everything that you asked me to.Still same exception.

Regards,

Parminder

Former Member
0 Kudos

Hmmm. Mail me the project u are working on :). Can't make out the reason here..

Please check my mail ID in my business card.In the mean time.. check out the tutorials in SDN on the same topic.. and see if u have missed somethin !

Former Member
0 Kudos

Hi,

IllegalArguementException problem got solved. I just changed the addElement to bindElement for the context element to which I was adding the data byte array , to add it to the context node. I am surprised how it made so much of difference. Thanks a lot for your guidance and hints.

I am left with now two small problems.

I am downloading 4 types of files - .uconfig, .config, .txt, .bat - .txt and .bat are getting downloaded properly but for the other files the download dialog box does not show any FILETYPE . Also it adds .txt to the files when saving to disk. How can I make it accept all the file types I am using.

I want to fire start the download of a file from code rather than user clicking on the FileDownload control. Can we somehow fire it from the code.

Can you please suggest something.

Regards,

Parminder

Former Member
0 Kudos

Hi Parminder,

Hmmm.You had said.. you got the same exception with a value attribute that was directly under the node.. Thats strange.

Ok.For your MIMETYPE problem, dont set the mimetype and try.(i.e) Dont use setMimeType() at all.

Second, you cannot trigger a automatic download without the UI element.

Regads

Bharathwaj