on 02-01-2011 12:03 PM
Hi,
I am developing NW Mobile Handheld application with 7.10 SP10 IDE. I want to upload an image and send it to DOE. I have created a model in DOE and imported the same in NWDS. The data type for the attachment attribute generated is BLOB as expected. My question is how do i create BLOB object so that i can fill the stream in it by reading a file. In laptop application i could see createBLOB() method in model instance to create BLOB object. But i couldnt see it in model class generated in PDA application.
Regards,
Dhana
Hi Dhana,
Here is the sample code:
public void onActionCreate (Event wdEvent) {
//@@begin onActionCreate(ServerEvent)
try {
AttahtstModel model = (AttahtstModel) OcaRoot.getInstance().getOcaModel(AttahtstModel.class);
AttachmentDataObjectAttachment element = model.createAttachmentDataObjectAttachment();
element.setAttachmentId(-1);
element.setAttachmentClob("X");
element.setAttachmentBlob("X");
element.setAttachmentClobActual("This is a new record");
BLOB blob = (BLOB) element.getAttachmentBlobActual();
InputStream is = blob.getBinaryStream();
String mobileHome = new File(Configuration.getInstallationDirectory()).getCanonicalPath();
String imageName = "image_new.jpg";
File imageFile = new File(mobileHome "
MobileApps
demo.sap.comattuiimplementation
Components
com.sap.demo.attui.wd.comp.attachmentcomp.AttachmentComp
"imageName);
FileInputStream fis = new FileInputStream(imageFile);
blob.setBinaryStream(fis, imageFile.length());
OcaRoot.getInstance().commit();
wdContext.currentContextElement().nodeAttachmentDataObjectAttachment().bind(model.getAttachmentDataObjectAttachments());
wdContext.reload();
} catch (Exception e) {
e.printStackTrace();
}
//@@end
}
Thanks and Regards,
Suma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.