on 04-21-2010 8:59 AM
Hi
Friends One Doubt in WDJ
Note: In This Application my Requirement is I want browse file from Desktop and click on upload button that file will move to EP Server of the particular path
That Path C://user/SAP/CED/ViewDemandForecast..
When click on Upload button that file will saved in under u201CViewDemandForecastu201D Folder.ViewDemandForecast is our Own Folder. We will create manuvally.
I have to write some code but it is not working can u check it. Where is the problem pls inform to me.
public void onActionUploadASNFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String srFile, java.lang.String dtFile )
{
//@@begin onActionUploadASNFile(ServerEvent)
try
{
File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
wdComponentAPI.getMessageManager().reportSuccess("File::"+file);
FileOutputStream fop=new FileOutputStream(file);
if(file.exists())
{
String path = "C://user/SAP/CED/ViewDemandForecast"+file;
//FileOutputStream op = new FileOutputStream("D://KumarDev-BackUp//"+file);
wdComponentAPI.getMessageManager().reportSuccess("path:"+path);
//wdComponentAPI.getMessageManager().reportSuccess("op:"+op);
fop.write(path.getBytes());
//fop.write(str1.getBytes());
fop.flush();
fop.close();
}
else
{
wdComponentAPI.getMessageManager().reportSuccess("File Not Found in Browse");
}
}
catch(IOException e)
{
e.printStackTrace();
}
//@@end
}
Regards
Vijay Kalluri
HI Vijay,
From your code, I see that in the if condition you are checking if the file exists, then u are creating under the path of the EP server.
I feel u shuld create only if the file does not exist. Kindly let me if I have answered your problem?
Since the file does not exist when u click on upload, the control goes to the else part and displays the message. Try using the
if(!file.exists())
if(file.exists())
{
String path = "C://user/SAP/CED/ViewDemandForecast"+file;
//FileOutputStream op = new FileOutputStream("D://KumarDev-BackUp//"+file);
wdComponentAPI.getMessageManager().reportSuccess("path:"+path);
//wdComponentAPI.getMessageManager().reportSuccess("op:"+op);
fop.write(path.getBytes());
//fop.write(str1.getBytes());
fop.flush();
fop.close();
}
else
{
wdComponentAPI.getMessageManager().reportSuccess("File Not Found in Browse");
}
Regards,
Poojith MV
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Friend
I am doing like this 1.Create one Application Open FirtsView in that FV i have Created 2 attaributes 1. data and 2. Resource (datatype---Resource) Now Open the FileUplaod UI Element and bind to the these two attribues.
after that i was created one button. in that button action i was write this code
public void onActionUpload(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )*
{
//@@begin onActionUpload(ServerEvent)
//$$begin ActionButton(1889399541)
InputStream text = null;
int temp = 0;
try
{
File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
FileInputStream in = new FileInputStream(file);
FileOutputStream op = new FileOutputStream(file);
if (wdContext.currentContextElement().getResource()!= null)
{
text = wdContext.currentContextElement().getResource().read(false);
while((temp=text.read())!= -1)*
{
op.write(temp);
}
}
op.flush();
op.close();
path = "Y:\sc\MJD"+file;
}
catch(Exception ex)
{
ex.printStackTrace();
}
//@@end
}
My Req is Browse the from any location and click on Upload button that file moves to Y:\sc\MJD\ this Path
I need some help from yours side.
Regards
Vijay Kalluri
Hi Friend
I am doing like this 1.Create one Application Open FirtsView in that FV i have Created 2 attaributes 1. data and 2. Resource (datatype---Resource) Now Open the FileUplaod UI Element and bind to the these two attribues.
after that i was created one button. in that button action i was write this code
public void onActionUpload(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )*
{
//@@begin onActionUpload(ServerEvent)
//$$begin ActionButton(1889399541)
InputStream text = null;
int temp = 0;
try
{
File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
FileInputStream in = new FileInputStream(file);
FileOutputStream op = new FileOutputStream(file);
if (wdContext.currentContextElement().getResource()!= null)
{
text = wdContext.currentContextElement().getResource().read(false);
while((temp=text.read())!= -1)*
{
op.write(temp);
}
}
op.flush();
op.close();
path = "Y:\sc\MJD"+file;
}
catch(Exception ex)
{
ex.printStackTrace();
}
//@@end
}
My Req is Browse the from any location and click on Upload button that file moves to Y:\sc\MJD this Path
I need some help from yours side.
Regards
Vijay Kalluri
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.