on 12-18-2008 1:22 PM
Hi Experts,
I have a requirement in my application, that list out the files from the server in table and also delete the file. Pls specify the code.
Regards,
Kiruba.R
If you have the source file path (eg: dirpath\filename.txt), then its possible to upload a file without using the FileUpload UI element..
vinod
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Could you be more specific about your requirement.
Regards
PG.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In my application, I have uploaded the files to the server. Next I have to display the uploaded files in the table as a linkTo action(e.g some 10 files).When I click the link the files conetent sholud display. After displaying the files, I need to delete the files from server one by one.
Regards,
Kiruba.R
Hi
List all the files from server
public void listServerFiles( )
{
//@@begin listServerFiles()
wdContext.nodeFiles().invalidate();
IPrivateExperimentView.IFilesElement element;
java.io.File file = new java.io.File( "D:\\Test");
File list[] = file.listFiles();
for( int i = 0; i < list.length; i++)
{
element = wdContext.createFilesElement();
element.setFileName( list[ i].getName());
wdContext.nodeFiles().addElement( element);
}
//@@end
}
Display the selected file
public void onActiondownload(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActiondownload(ServerEvent)
IWDResource resource;
String name = wdContext.currentFilesElement().getFileName();
String path = "D:\\Test\\" + 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();
}
Delete the selected file
public void onActiondeleteFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActiondeleteFile(ServerEvent)
String path = "D:\\Test\\" + wdContext.currentFilesElement().getFileName();
File file = new File( path);
file.delete();
listServerFiles();
//@@end
}
vinod
User | Count |
---|---|
74 | |
26 | |
11 | |
10 | |
7 | |
6 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.