on 04-08-2014 8:29 AM
Hi,
I have a file upload ui element in WD java which is bound to iwdresource attribute of name resource. I have an upload button. WHen i click on upload when no file is uploaded, I must show an error message telling "Please select a file for upload". Can anyone assist mew with the code?? Also I want the resource name to be set in my file input ui element like this
Hi Sakshi,
Check resource is equal to null in side upload action.
if it is null then show message.
Use following code.
if(wdContext.currentContextElement().getResource==null){
wdComponentAPI.getMessageManager().reportException("Please select file.");
}else{
}
Thanks,
Moreshwar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Sakthi,
You can set the file name in file input UI element( IPrivateFileUploadView.IContextElemen) like this.
public void onActionUploadFile(
com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent) {
//@@begin onActionUploadFile(ServerEvent)
IPrivateFileUploadView.IContextElement element = wdContext.currentContextElement();
...
// if a file in the FileUpload field exists
if (element.getFileResource() != null) {
IWDResource resource = element.getFileResource();
...
// set context attribute 'fileName' .
element.setFileName(resource.getResourceName());
...}
Read following document for better understanding.
Thanks & Regards,
Patralekha
hi Sakthi,
you can get the file name by using the
wdContext.currentFileUploadElement().getResource().getResourceName();
I dont think you can set name of a file being uploaded which already has a name, but u can change the name by creating another file .
use java code to create a new file 'with new name with data from the file that you upload, and give a name to the file that you desire.
can u just breifly explain what exactly you wanted to achieve...
like just uploading file or upload file and store this file at other location with new name ?
Regards
Govardan
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.