on 11-16-2007 6:59 AM
Hi,
I added a FileUpload UI element.
I created an attribute of type resource , assigned to the resource property of the file upload element.
I created an action button called upload and added the following code.
try {
IWDResource resource = wdContext.currentContextElement().getFileupload();
} catch (Exception e) {
e.printStackTrace();
}
when I debug to see the value of resource it is null.
Please let me know where I am going wrong.
Regards,
Narayani
Hi Narayani,
Please go to the followinf code. This code take the Resource object and bind it to the respective resouce.
Hope this will help you.
try{
String path = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(),"LocalConveyance.pdf"); // gets the path of local object.
try{
InputStream stream = new FileInputStream(path);
IWDResource LocalConveyanceResource = WDResourceFactory.createResource(stream, "LocalConveyance.pdf", WDWebResourceType.PDF, true);
wdContext.currentContextElement().setLocalConveyanceTarget(LocalConveyanceResource); //LocalConveyanceTarget is the context with type RESOURCE.
wdContext.currentContextElement().getLocalConveyanceTarget();
}
catch(IOException b)
{
b.getMessage();
}
}
catch(WDAliasResolvingException e)
{
e.getMessage();
}
Regards,
Roshan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
closed as an OSS message was raised
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Which version of NWDS are you using ?
try{
IWDResource resource = wdContext.currentContextElement().getFileupload();
if(resource() != null)
wdComponentAPI.getMessageManager().reportSuccess(resource.getResourceName());
else{w
dComponentAPI.getMessageManager().reportWarning("Please upload the Document ");
}
} catch (Exception e) {
dComponentAPI.getMessageManager().reportWarning(e.getMessage());
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Narayani,
What type of file are you trying to upload? Is that an XML file? Can you try checking the other file formats like word, excel, etc...
Regards,
Rekha Malavathu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check this:
// Appendix is the context node
IPrivateFreightRequestComponentView.IAppendixElement
element = wdContext.currentAppendixElement();
// if a file in the FileUpload field exists
if (element.getUploadFile() != null)
{
IWDResource resource = element.getUploadFile();
// get the size of the uploaded file => separate method
element.setFileSize(this.getFileSize(resource));
<b>// get the extension of the uploaded file
element.setFileExtension( resource.getResourceType().getFileExtension());</b>
// set context attribute 'fileName' .
element.setFileName(resource.getResourceName());
// set the details visibility attribute
element.setDetailsVisibility(WDVisibility.VISIBLE);
}
else
{
// if no file in the FileUpload field exists
}
Hi,
Check if there are any space characters in your uploading path (file path).
First try to upload a file without any space characters in the uploading path(file path). If the problem is with the space characters then use the below encoding & decoding to resolve that issue.
Encoding while uploading the file:
// Getting the file resource
IWDResource resource = element.getCtx_va_FileResource();
//Getting the resource name
String resourceName = resource.getResourceName();
//Encoding the resource name
String encoderesourceName = java.net.URLEncoder.encode(resourceName,"UTF-8");
Again while downloading you can use decoder.
Hope this helps to resolve your issue.
See this below link.
Try this encoding even if there are no space characters.
Regards,
Charan
Hi Narayani,
Can you try printing the catch block to the Web Dynpro view?
Also check if the view controller's fileupload attribute is mapped to the component controllers fileupload attribute.
Regards,
Rekha Malavathu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Refer this link. U cau get a clear idea
/people/raja.thangamani/blog/2007/11/12/how-to-create-attachments-in-business-transaction-from-webdynprojava
Regards,
karthik.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The data property will be the first property of FileUpload UI.
Try this link
Regards,
karthik
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.