cancel
Showing results for 
Search instead for 
Did you mean: 

FileUpload, How to use?

htammen
Active Contributor
0 Kudos

Hi,

I wanted to use the Fileupload control. So I placed the visual control on a View and bound the data attribute to a binary attribute of the context. Addionally I placed a Button on my view in which action handler I wanted to read the data of the file into a Stream or Byte array.

my context attribute does always have the value null.

So, how can I use the Fileupload control?

Thanks in advance

Helmut

Action handler:

  public void onActionUploadXML(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

  {

    //@@begin onActionUploadXML(ServerEvent)

    // The name of my context attribute is xmlFile

    byte[] xmlArr = wdContext.currentContextElement().getXmlFile();

    for(int i=0; i;

    }

    ...

    //@@end

  }

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member322327
Participant
0 Kudos

Hi everyone:

Somebody knows, where can I download an example of ui FileUpload?

Thanks.

Eduardo Campos

Former Member
0 Kudos

I need the sample code for upload and download file too. Karin Schattka, could you put that sample project to sapmats again? Thanks in advance.

Jun

Former Member
0 Kudos

Hi All,

Please find the sample application here:

http://sapmats-de.sap-ag.de/download/download.cgi?id=OAJ5JDEMWR40D2OAC7XAZ2PCAZBM7I2DW7F99NNZLXOYKZR...

It will be available for the next 100 days.

Best regards, Karin

Former Member
0 Kudos

Hi Karin,

It's a good sample application. Thank you very much.

Best regards,

Jun

Former Member
0 Kudos

Hi Karin,

I get this

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: C:\WINNT\Web\Wallpaper\Snow Trees.jpg (The system cannot find the path specified)

at com.sap.sb.View1.wdDoInit(View1.java:136)

at com.sap.sb.wdp.InternalView1.wdDoInit(InternalView1.java:133)

...

on both my German Win2000 and on my XP machine.

There is some hardcoded wallpaper required. No problem to copy a file to this directory, but should be improved.

The example is very helpful,

thanks

Walter

Former Member
0 Kudos

I'm ashamed,

I found I can change this in View1.java myself.

Walter

0 Kudos

Hello,

the link pointing to uplaod & Download file is not working anymore. Could you please re-post or check it.

THanks a lot.

Patrice

Former Member
0 Kudos

Hi Patrice,

Please use the following link. Should work for the next 100 days. It will be available soon within the matrix.

Best regards,

Karin

http://sapmats-de.sap-ag.de/download/download.cgi?id=5K7EPLB7EVF9CXQUXGEJNNMSYWZ8XX8VUQDU61CO88MT7ND...

Former Member
0 Kudos

This project is using DTR ..That's why we didn't had the access to change the file. What you have to do is :

1.In the package Explorer View, traverse to the path webdynprotest_fileUpDownload->src->packages->com->sap->sb

2.Right Click on the following files, take "Properties" and uncheck the "Read Only" access.

View1.wdcontroller,View1.wdcontroller.xlf,View1.wdcontroller_en.xlf,View1.wdview,View1.wdview.xlf,View1.wdview_en.xlf

Now the View will be set to edit mode and you could change the files.

Thanks and Regards,

Sam Mathew

Former Member
0 Kudos

Hi Karin,

can you give me a working link for the file upload example again? This would be a great help as the documentation is not really sufficient to get the upload running.

Thanks,

Konrad

Former Member
0 Kudos

[... issue resolved...,

see ;

]

Message was edited by: Holger Assenmacher

Former Member
0 Kudos

Hi Helmut,

Did you place an additional Button on your view? The UI element FileUpload appears with an input field, in which the directory path and the file name appear, and a button for searching for the file. The data property determines the data drain in the context. The fileName property contains the file name.

The data property must be bound to this value attribute of data type binary, so that the file can be uploaded as a byte array. At runtime, the binary data type can be enriched with data to allow the passing of related information when uploading a file. To do this, you must implement the following source text in the wdDoInit method of the controller implementation, with which the binary data type is enhanced with additional information at runtime:

  public void wdDoInit()

  {

    //@@begin wdDoInit()

// The FileUpload UI element requires:

IWDAttributeInfo attInfo = wdContext.nodeRoot().getNodeInfo().getAttribute("FileUpload");    

binaryType = (IWDModifiableBinaryType) attInfo.getModifiableSimpleType();

    //@@end

  }

In addition, you can use the IWDModifiableBinaryType data type, which represents an extension of the binary data type, to access the MIME type of the file, that is, either read or set the MIME type or read or set the file name of the Web resource.

Hope that helps!

Karin

htammen
Active Contributor
0 Kudos

Thanks Karin for repeating the documentation. I wouldn´t have asked if I understood it (or its complete?).

Of course do I have an additional button that is bound to the above mentioned action. The data property of my FileUpload control is also bound to a binary attribute value of the view context.

When pressing the upload button (my additional button) after selecting a file via the browse button of the FileUpload control I get either one these errors:

1. If the action is a validating action

The validating exception "Parse method is not possible for this type" is thrown so that my action handler is never called.

2. If the action is a non-validating action

The context property that is bound to the data property of the FileUpload control is null.

Do you have an example or did someone at SAP use this control?

Thanks in advance again

Helmut

Former Member
0 Kudos

give me another try!

Former Member
0 Kudos

Hello Helmut,

Please find a sample application here:

http://sapmats-de.sap-ag.de/download/download.cgi?id=RN8K5R4NCB1D5BLZ8B2X9NYOCAIW1OX0U0AH9EVN0DAC2UF...

Hope that helps!

Karin

Former Member
0 Kudos

Hi Karin,

I use the version 2.2 of netweaver but I can't see any Upload or Download UI-element.

In which version are these elements available?

Thorsten

Former Member
0 Kudos

Hi together,

I have found an example Project to download with

an Upload und Download UI-element. When I open this

project, I obtain the following message:

Missing required library: 'C:Programme/SAP/JDT/eclipse/plugins/com.sap.tc.col/lib/_col_cxm.jar'.

Missing required library: 'C:Programme/SAP/JDT/eclipse/plugins/com.sap.tc.col/lib/_col_edo.jar'.

Missing required library: 'C:Programme/SAP/JDT/eclipse/plugins/com.sap.tc.col/lib/_col_rpe.jar'.

Missing required library: 'C:Programme/SAP/JDT/eclipse/plugins/com.sap.tc.col/lib/_col_servicemanager.jar'.

Missing required library: 'C:Programme/SAP/JDT/eclipse/plugins/com.sap.tc.webdynpro.runtime/lib/_webdynpro_runtime_repository_pmr.jar'.

Missing required library: 'C:Programme/SAP/JDT/eclipse/plugins/com.sap.tc.webdynpro.runtime/lib/_webdynpro_runtime_repository.jar'.

because I have only a 2.0.2 version of the IDE. Can anyone of you, who has the up and download UI-Elements running zip the plugin packages "com.sap.tc.col" and "com.sap.tc.webdynpro.runtime" and send to T.Rottschaefer2@DeutschePost.de? I will try to get the Up-Download elements running with these WebDynpro-plugins.

Thanks - Thorsten

Former Member
0 Kudos

Hello Thorsten,

In Sneak Preview II is FileUplaod and FileDownLoad available. NetWeaver 2.2 is not a version I am aware off. What is the IDE and the J2EE version?

Thanks, Karin

Former Member
0 Kudos

Hello,

unfortunately is the above link from karin not working anymore. does anyone know a tutorial or an example application for the file upload?

Thanks,

Erich

Former Member
0 Kudos

Hi All,

I am using Netweaver developer studio 2.0.7 version.

I want to use the Fileupload control. I checked the link in SDN forum but I can't see any Upload or Download UI-element.

On clicking the button i want to upload a file, read the contents of the file and INSERT the same in SAP database. I want to pass the "<b>FilePath</b>" (as a STRING) to an RFC which will do the INSERTION part. Please help me in this regard urgently.

I've checked the documentation also in Help -NDS.

Do you have any example regarding this.

<b>Regards,

Sai.</b>

Former Member
0 Kudos

HI for Uploading a file

In the view create a FileUpload UI element and a button and then in the context create a <b>node</b> say "File" which has all the properties that u require for ur file to have. i take filename attribute of string type and one more attribute source of binary type where i store all the contents of the file whether teh file if of any format may be doc type or .xls format ok. Then the cardinality and selection property of the node File should be 1..n .

Create an element of that node globally and write the following code in init

element1 = wdContext.createFileElement();

wdContext.nodeFile().bind(element1);

IWDAttributeInfo attInfo =

wdContext.nodeFile().getNodeInfo().getAttribute("binary");

//this binary is teh attribute of ur context of type //binary

ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();

IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) type;

binaryType.setFileName("Test.txt");

//by default the filename will be test even u need not set //it

now on acion of the button u created add this code

try {

File file = new File("c:\test.txt");

FileOutputStream out = new FileOutputStream(file);

if(element1.getBinary() != null)

out.write(element1.getBinary());

else

wdComponentAPI.getMessageManager().reportSuccess("The data is null");

out.close();

}

and catch that s it it will upload ur file into the server

in c: as u mentioned so u have to download that into ur client if u want for further process.