on 10-27-2006 7:36 AM
Dear All,
I am new in webdynpro development and I have a requirement to develop a webdynpro application which can save a document in a specified file directory. Can somebody please suggest or give sample code as to how to develope this application ...so that i can understand how to go about it.
Awaiting response.
Thank You.
Ranu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Mukesh ,
Thank you for your prompt reply. Well as suggested by you I tried developing a small webdynpro application with the UI element FileUpload and a button Save. Then I added the code as mentioned by you in onActionSave. Here I am getting a few errors for the extract of code mentioned below:-
fname = files.getName();
final InitialContext ctx1 = new InitialContext();
final DestinationService dstService1 = (DestinationService)ctx1.lookup(DestinationService.JNDI_KEY);
The Errors are
1.fname cannot be resolved
2.DestinationService cannot be resolved or is not a type.
Can you please tell me what i am missing out.
Thank you.
Ranu
Hi Ranu,
Did you added the reference in webdynpro project:
Do this step also:
(1) In the Package explorer, select your project, right click, cick on "Set Additional Libraries.."
(2) Select security.class and tc/sec/destinations/interface
(3) Click on menu Project > Properties, goto Webdynpro refereces node in the tree and add the following
(a) Interface References: tcsecdestinations~interface
(b) Service References: tcsecdestinations~service
Check this thread too:
Regards, Suresh KB
Dear Suresh,
Thank you for your prompt reply. Well as suggested by you , I have done the part of " Set Additional Libraries " and " WebDynpro References". The error which was earlier come of DestinationService cannot resolved is no longer coming .
Now the errors are
1.fname cannot be resolved( this was there earlier too)
2.Type mismatch: cannot convert from com.sap.security.core.server.destinations.api.Destination to javax.print.attribute.standard.Destination
Please advise.
Thank you.
Ranu
Hi Ranu,
Check my previous reply link: I think you imported wrong packages. is your packages same like this?
import com.sap.security.core.server.destinations.api.Destination;
import com.sap.security.core.server.destinations.api.DestinationService;
import com.sap.security.core.server.destinations.api.HTTPDestination;
Regards, Suresh KB
Dear Suresh,
Thank you very much for your helpful answer.I have rectified the imports. Now the only error that is still persistent is "fname cannot be resolved ".
I am attaching the code snippet that I have written in the part onActionSave for your perusal.Can you please look into it and let me know where I am making a mistake.
public void onActionSave(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionSave(ServerEvent)
byte imgsource[] = wdContext.currentDataElement().getDocument();
String filePath = wdContext.currentDataElement().getFileName();
byte[] fileBytes; //an array of bytes
try {
File files = new File(filePath);
fname = files.getName();
final InitialContext ctx1 = new InitialContext();
final DestinationService dstService1 = (DestinationService)ctx1.lookup(DestinationService.JNDI_KEY);
final Destination destination1 = dstService1.getDestination("HTTP", "document");
//specify the Http destination as document
fileBytes = imgsource; //create a byte array from contents of field
String docuurl = "http://impp11.pune.telco.co.in:50000/irj/portal/+fname";
OutputStream targetFile = new FileOutputStream(docuurl);
//define the output stream
targetFile.write(fileBytes); //write the array of bytes to file
targetFile.close(); //close the File stream
} catch (Exception e) {
e.printStackTrace();
wdComponentAPI.getMessageManager().reportSuccess(e.getMessage());
}
}
Thank You.
Ranu
Dear Suresh and Mukesh ,
Thank you, for all the help that you have provided. I have successfully created the webdynpro application to upload a document in a particular directory. There is still some problem with the destination configuration but that is being looked into by system admin. I shall get back to you if i face any problems but for the time being thank you very much for the help provided.
Regards,
Ranu
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.