on 07-21-2006 5:58 AM
Hi
I have done the tabstip example... i have created two Tabs
EDIT and DISPLAY.... its working fine... but image is not working.... i am uploading the image file in EDIT VIEW when i click save button it has to display in DISPLAY VIEW... but when i click save i am getting
<b>"NULL POINTER EXCEPTION"</b>
i have wrrinten the following code in "onActionSave()"
public void onActionSave(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionSave(ServerEvent)
/* System.out.println("Ravi");*/
wdThis.wdGetUIComponentController().preparationForFileDownload();
IPrivateEditMyDataView.IMyDataElement myDataElement = wdContext.currentMyDataElement();
if (myDataElement != null) {
myDataElement.setFile(myDataElement.getPicture());
}
//$$end
//image source change
if(wdContext.currentMyDataElement().getPictureName() == null){
wdContext.currentImageElement().setDefault(false);
}
else{
wdContext.currentImageElement().setDefault(true);
}
//@@end
}
<b>preparationForFileDownload();this method i have implemented in UIComponent class
</b>public void PreparationForFileDownload( )
{
//@@begin PreparationForFileDownload()
IWDAttributeInfo attInfo = wdContext.nodeMyData().getNodeInfo().getAttribute("File");
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) attInfo.getModifiableSimpleType();
//in addition the FileDownload UI element needs for defined resource types
binaryType.setFileName(wdContext.currentMyDataElement().getAttributeAsText("PictureName"));
binaryType.setMimeType(WDWebResourceType.JPG_IMAGE);
//@@end
}
I am getting error on the following line
wdContext.currentImageElement().setDefault(true); in
onActionSave() method of EditView....
Please Help Me....
Thanks & Regards
Ravi Shankar B
Hi Ravi,
Check The Cardinality of the node Image and set cardinality is 1..1 of 0..1
Kind Regards
Mukesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think ur using file download,
Follow the steps:
1)Put ur images in src>mimies>compoments.
create an attribute fileresource and declare the
image as FILE_NAME =image.JPEG globally
2)write the code in meathod() or action
[code]IWDAttributeInfo attributeInfo =wdContext.getNodeInfo().getAttribute(IPrivateFiledownloadappView.IContextElement.FILERESOURCE);
binaryType =(IWDModifiableBinaryType)attributeInfo.getModifiableSimpleType()binaryType.getFileName();
try {
String resourcePath =
WDURLGenerator.getResourcePath(
wdComponentAPI.getDeployableObjectPart(),
FiledownloadappView.FILE_NAME);
wdContext.currentContextElement().setFileresource(
this.getByteArrayFromResourcePath(resourcePath));
binaryType.setFileName(FiledownloadappView.FILE_NAME);
binaryType.setMimeType(WDWebResourceType.JPEG);
} catch (WDAliasResolvingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
3)write the getByteArrayFromResourcePath method code in
//@@begin others
private byte[] getByteArrayFromResourcePath(String resourcePath)
throws FileNotFoundException, IOException {
FileInputStream in = new FileInputStream(new File(resourcePath));
ByteArrayOutputStream out = new ByteArrayOutputStream();
int len;
byte[] part = new byte[10 * 1024];
while ((len = in.read(part)) != -1) {
out.write(part, 0, len);
}
in.close();
return out.toByteArray();
}
//store image file name in constant FILE_NAME
IWDModifiableBinaryType binaryType ;
private static final String FILE_NAME = "image.JPEG";
//@@end
Regards,
Vijayakhanna Raman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
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.